bitwarden-estensione-browser/src/models/view/loginView.ts

58 lines
1.3 KiB
TypeScript
Raw Normal View History

import { LoginUriView } from './loginUriView';
2018-01-24 17:33:15 +01:00
import { View } from './view';
import { Login } from '../domain/login';
2018-01-24 17:33:15 +01:00
import { PlatformUtilsService } from '../../abstractions/platformUtils.service';
2018-01-24 17:33:15 +01:00
export class LoginView implements View {
username: string;
totp: string;
uris: LoginUriView[];
2018-01-24 17:33:15 +01:00
2018-01-24 22:58:34 +01:00
// tslint:disable
private _username: string;
private _password: string;
private _maskedPassword: string;
// tslint:enable
2018-01-24 17:33:15 +01:00
constructor(l?: Login) {
// ctor
}
2018-01-24 22:58:34 +01:00
get password(): string {
return this._password;
}
set password(value: string) {
this._password = value;
this._maskedPassword = null;
}
get uri(): string {
return this.hasUris ? this.uris[0].uri : null;
2018-01-24 17:33:15 +01:00
}
2018-01-24 22:58:34 +01:00
get maskedPassword(): string {
if (this._maskedPassword == null && this.password != null) {
this._maskedPassword = '';
2018-01-25 05:27:04 +01:00
for (let i = 0; i < this.password.length; i++) {
2018-01-24 22:58:34 +01:00
this._maskedPassword += '•';
}
}
return this._maskedPassword;
}
get subTitle(): string {
return this.username;
}
2018-01-25 05:27:04 +01:00
get canLaunch(): boolean {
return this.hasUris && this.uris[0].canLaunch;
2018-01-25 05:27:04 +01:00
}
get hasUris(): boolean {
return this.uris != null && this.uris.length > 0;
2018-01-25 05:27:04 +01:00
}
2018-01-24 17:33:15 +01:00
}