2018-03-02 05:44:29 +01:00
|
|
|
import { LoginUriView } from './loginUriView';
|
2018-01-24 17:33:15 +01:00
|
|
|
import { View } from './view';
|
|
|
|
|
2020-12-15 17:02:54 +01:00
|
|
|
import { Utils } from '../../misc/utils';
|
2018-02-19 19:07:19 +01:00
|
|
|
import { Login } from '../domain/login';
|
2018-01-24 17:33:15 +01:00
|
|
|
|
|
|
|
export class LoginView implements View {
|
2019-01-25 15:30:21 +01:00
|
|
|
username: string = null;
|
|
|
|
password: string = null;
|
|
|
|
passwordRevisionDate?: Date = null;
|
|
|
|
totp: string = null;
|
|
|
|
uris: LoginUriView[] = null;
|
2021-05-18 02:08:28 +02:00
|
|
|
autofillOnPageLoad: boolean = null;
|
2018-01-24 17:33:15 +01:00
|
|
|
|
|
|
|
constructor(l?: Login) {
|
2018-07-27 23:48:18 +02:00
|
|
|
if (!l) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.passwordRevisionDate = l.passwordRevisionDate;
|
2021-05-18 02:08:28 +02:00
|
|
|
this.autofillOnPageLoad = l.autofillOnPageLoad;
|
2018-01-24 17:33:15 +01:00
|
|
|
}
|
|
|
|
|
2018-03-02 05:44:29 +01:00
|
|
|
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 {
|
2018-03-06 13:44:32 +01:00
|
|
|
return this.password != null ? '••••••••' : null;
|
2018-01-24 22:58:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get subTitle(): string {
|
|
|
|
return this.username;
|
|
|
|
}
|
2018-01-25 05:27:04 +01:00
|
|
|
|
2018-03-02 05:44:29 +01:00
|
|
|
get canLaunch(): boolean {
|
2021-02-04 16:49:23 +01:00
|
|
|
return this.hasUris && this.uris.some(u => u.canLaunch);
|
2018-01-25 05:27:04 +01:00
|
|
|
}
|
|
|
|
|
2020-12-15 17:02:54 +01:00
|
|
|
get hasTotp(): boolean {
|
|
|
|
return !Utils.isNullOrWhitespace(this.totp);
|
|
|
|
}
|
|
|
|
|
2019-01-07 16:33:13 +01:00
|
|
|
get launchUri(): string {
|
2019-02-08 14:01:08 +01:00
|
|
|
if (this.hasUris) {
|
2021-02-04 16:49:23 +01:00
|
|
|
const uri = this.uris.find(u => u.canLaunch);
|
2019-02-08 14:01:08 +01:00
|
|
|
if (uri != null) {
|
|
|
|
return uri.launchUri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
2019-01-07 16:33:13 +01:00
|
|
|
}
|
|
|
|
|
2018-03-02 05:44:29 +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
|
|
|
}
|