mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-24 16:49:26 +01:00
support for password revision date on logins
This commit is contained in:
parent
6d431f7832
commit
6a8d2c305e
@ -4,11 +4,13 @@ export class LoginApi {
|
||||
uris: LoginUriApi[];
|
||||
username: string;
|
||||
password: string;
|
||||
passwordRevisionDate?: Date;
|
||||
totp: string;
|
||||
|
||||
constructor(data: any) {
|
||||
this.username = data.Username;
|
||||
this.password = data.Password;
|
||||
this.passwordRevisionDate = data.PasswordRevisionDate;
|
||||
this.totp = data.Totp;
|
||||
|
||||
if (data.Uris) {
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { LoginApi } from '../api/loginApi';
|
||||
import { LoginUriApi } from '../api/loginUriApi';
|
||||
|
||||
import { LoginUriData } from './loginUriData';
|
||||
|
||||
@ -7,6 +6,7 @@ export class LoginData {
|
||||
uris: LoginUriData[];
|
||||
username: string;
|
||||
password: string;
|
||||
passwordRevisionDate?: Date;
|
||||
totp: string;
|
||||
|
||||
constructor(data?: LoginApi) {
|
||||
@ -16,6 +16,7 @@ export class LoginData {
|
||||
|
||||
this.username = data.username;
|
||||
this.password = data.password;
|
||||
this.passwordRevisionDate = data.passwordRevisionDate;
|
||||
this.totp = data.totp;
|
||||
|
||||
if (data.uris) {
|
||||
|
@ -2,7 +2,6 @@ import { LoginUri } from './loginUri';
|
||||
|
||||
import { LoginData } from '../data/loginData';
|
||||
|
||||
import { LoginUriView } from '../view/loginUriView';
|
||||
import { LoginView } from '../view/loginView';
|
||||
|
||||
import { CipherString } from './cipherString';
|
||||
@ -12,6 +11,7 @@ export class Login extends Domain {
|
||||
uris: LoginUri[];
|
||||
username: CipherString;
|
||||
password: CipherString;
|
||||
passwordRevisionDate?: Date;
|
||||
totp: CipherString;
|
||||
|
||||
constructor(obj?: LoginData, alreadyEncrypted: boolean = false) {
|
||||
@ -20,6 +20,7 @@ export class Login extends Domain {
|
||||
return;
|
||||
}
|
||||
|
||||
this.passwordRevisionDate = obj.passwordRevisionDate;
|
||||
this.buildDomainModel(this, obj, {
|
||||
username: null,
|
||||
password: null,
|
||||
@ -54,6 +55,7 @@ export class Login extends Domain {
|
||||
|
||||
toLoginData(): LoginData {
|
||||
const l = new LoginData();
|
||||
l.passwordRevisionDate = this.passwordRevisionDate;
|
||||
this.buildDataModel(this, l, {
|
||||
username: null,
|
||||
password: null,
|
||||
|
@ -39,6 +39,7 @@ export class CipherRequest {
|
||||
uris: null,
|
||||
username: cipher.login.username ? cipher.login.username.encryptedString : null,
|
||||
password: cipher.login.password ? cipher.login.password.encryptedString : null,
|
||||
passwordRevisionDate: cipher.login.passwordRevisionDate,
|
||||
totp: cipher.login.totp ? cipher.login.totp.encryptedString : null,
|
||||
};
|
||||
|
||||
|
@ -3,16 +3,19 @@ import { View } from './view';
|
||||
|
||||
import { Login } from '../domain/login';
|
||||
|
||||
import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
|
||||
|
||||
export class LoginView implements View {
|
||||
username: string;
|
||||
password: string;
|
||||
passwordRevisionDate?: Date;
|
||||
totp: string;
|
||||
uris: LoginUriView[];
|
||||
|
||||
constructor(l?: Login) {
|
||||
// ctor
|
||||
if (!l) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.passwordRevisionDate = l.passwordRevisionDate;
|
||||
}
|
||||
|
||||
get uri(): string {
|
||||
|
@ -69,12 +69,15 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
const existingCipher = await (await this.get(model.id)).decrypt();
|
||||
if (existingCipher != null) {
|
||||
model.passwordHistory = existingCipher.passwordHistory || [];
|
||||
if (model.type === CipherType.Login && existingCipher.type === CipherType.Login &&
|
||||
existingCipher.login.password !== model.login.password) {
|
||||
const ph = new PasswordHistoryView(null);
|
||||
ph.password = existingCipher.login.password;
|
||||
ph.lastUsedDate = new Date();
|
||||
model.passwordHistory.splice(0, 0, ph);
|
||||
if (model.type === CipherType.Login && existingCipher.type === CipherType.Login) {
|
||||
if (existingCipher.login.password !== model.login.password) {
|
||||
const ph = new PasswordHistoryView();
|
||||
ph.password = existingCipher.login.password;
|
||||
ph.lastUsedDate = model.login.passwordRevisionDate = new Date();
|
||||
model.passwordHistory.splice(0, 0, ph);
|
||||
} else {
|
||||
model.login.passwordRevisionDate = existingCipher.login.passwordRevisionDate;
|
||||
}
|
||||
}
|
||||
if (existingCipher.hasFields) {
|
||||
const existingHiddenFields = existingCipher.fields.filter((f) => f.type === FieldType.Hidden);
|
||||
@ -83,7 +86,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
existingHiddenFields.forEach((ef) => {
|
||||
const matchedField = hiddenFields.filter((f) => f.name === ef.name);
|
||||
if (matchedField.length === 0 || matchedField[0].value !== ef.value) {
|
||||
const ph = new PasswordHistoryView(null);
|
||||
const ph = new PasswordHistoryView();
|
||||
ph.password = ef.name + ': ' + ef.value;
|
||||
ph.lastUsedDate = new Date();
|
||||
model.passwordHistory.splice(0, 0, ph);
|
||||
@ -767,6 +770,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
switch (cipher.type) {
|
||||
case CipherType.Login:
|
||||
cipher.login = new Login();
|
||||
cipher.login.passwordRevisionDate = model.login.passwordRevisionDate;
|
||||
await this.encryptObjProperty(model.login, cipher.login, {
|
||||
username: null,
|
||||
password: null,
|
||||
|
Loading…
Reference in New Issue
Block a user