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