Added warning dialog for log out confirmation (#1216)

This commit is contained in:
Vincent Salucci 2020-04-25 09:13:00 -05:00 committed by GitHub
parent f636e3a957
commit 0b5cb901aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View File

@ -1257,5 +1257,11 @@
"lock": { "lock": {
"message": "Lock", "message": "Lock",
"description": "Verb form: to make secure or inaccesible by" "description": "Verb form: to make secure or inaccesible by"
},
"vaultTimeoutLogOutConfirmation": {
"message": "Logging out will remove all access to your vault and requires online authentication after the timeout period. Are you sure you want to use this setting?"
},
"vaultTimeoutLogOutConfirmationTitle": {
"message": "Timeout Action Confirmation"
} }
} }

View File

@ -33,8 +33,8 @@
</div> </div>
<div class="box-content-row display-block" appBoxRow> <div class="box-content-row display-block" appBoxRow>
<label for="vaultTimeoutAction">{{'vaultTimeoutAction' | i18n}}</label> <label for="vaultTimeoutAction">{{'vaultTimeoutAction' | i18n}}</label>
<select id="vaultTimeoutAction" name="VaultTimeoutActions" [ngModel]="vaultTimeoutAction" <select #vaultTimeoutActionSelect id="vaultTimeoutAction" name="VaultTimeoutActions"
(ngModelChange)="saveVaultTimeoutAction($event)"> [ngModel]="vaultTimeoutAction" (ngModelChange)="saveVaultTimeoutAction($event)">
<option *ngFor="let o of vaultTimeoutActions" [ngValue]="o.value">{{o.name}}</option> <option *ngFor="let o of vaultTimeoutActions" [ngValue]="o.value">{{o.name}}</option>
</select> </select>
</div> </div>

View File

@ -45,6 +45,7 @@ const RateUrls = {
}) })
export class SettingsComponent implements OnInit { export class SettingsComponent implements OnInit {
@ViewChild('vaultTimeoutSelect', { read: ElementRef }) vaultTimeoutSelectRef: ElementRef; @ViewChild('vaultTimeoutSelect', { read: ElementRef }) vaultTimeoutSelectRef: ElementRef;
@ViewChild('vaultTimeoutActionSelect', { read: ElementRef }) vaultTimeoutActionSelectRef: ElementRef;
vaultTimeouts: any[]; vaultTimeouts: any[];
vaultTimeout: number = null; vaultTimeout: number = null;
vaultTimeoutActions: any[]; vaultTimeoutActions: any[];
@ -126,6 +127,20 @@ export class SettingsComponent implements OnInit {
} }
async saveVaultTimeoutAction(newValue: string) { async saveVaultTimeoutAction(newValue: string) {
if (newValue === 'logOut') {
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('vaultTimeoutLogOutConfirmation'),
this.i18nService.t('vaultTimeoutLogOutConfirmationTitle'),
this.i18nService.t('yes'), this.i18nService.t('cancel'), 'warning');
if (!confirmed) {
this.vaultTimeoutActions.forEach((option: any, i) => {
if (option.value === this.vaultTimeoutAction) {
this.vaultTimeoutActionSelectRef.nativeElement.value = i + ': ' + this.vaultTimeoutAction;
}
});
return;
}
}
this.vaultTimeoutAction = newValue; this.vaultTimeoutAction = newValue;
await this.vaultTimeoutService.setVaultTimeoutOptions(this.vaultTimeout != null ? this.vaultTimeout : null, await this.vaultTimeoutService.setVaultTimeoutOptions(this.vaultTimeout != null ? this.vaultTimeout : null,
this.vaultTimeoutAction); this.vaultTimeoutAction);