mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
Password reprompt fixes (#926)
* Hide card number when hidden * Avoid double password prompts * Bump jslib
This commit is contained in:
parent
c89da7f12b
commit
c7345197f7
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit dddcc2bc93c15df4d9b6a38e7f9a76d01fe8b384
|
||||
Subproject commit 25a91313ad0441d1c02e043113f931f203fd57e6
|
@ -77,6 +77,7 @@ export class AddEditComponent extends BaseAddEditComponent implements OnChanges,
|
||||
|
||||
onWindowHidden() {
|
||||
this.showPassword = false;
|
||||
this.showCardNumber = false;
|
||||
this.showCardCode = false;
|
||||
if (this.cipher !== null && this.cipher.hasFields) {
|
||||
this.cipher.fields.forEach(field => {
|
||||
|
@ -9,7 +9,7 @@
|
||||
(onAddCipherOptions)="addCipherOptions()">
|
||||
</app-vault-ciphers>
|
||||
<app-vault-view id="details" class="details" *ngIf="cipherId && action === 'view'" [cipherId]="cipherId"
|
||||
(onCloneCipher)="cloneCipher($event)" (onEditCipher)="editCipher($event)"
|
||||
(onCloneCipher)="cloneCipherWithoutPasswordPrompt($event)" (onEditCipher)="editCipherWithoutPasswordPrompt($event)"
|
||||
(onViewCipherPasswordHistory)="viewCipherPasswordHistory($event)" (onRestoredCipher)="restoredCipher($event)"
|
||||
(onDeletedCipher)="deletedCipher($event)">
|
||||
</app-vault-view>
|
||||
|
@ -229,9 +229,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async viewCipher(cipher: CipherView) {
|
||||
if (this.action === 'view' && this.cipherId === cipher.id) {
|
||||
return;
|
||||
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
|
||||
if (!await this.canNavigateAway('view', cipher)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -328,11 +326,17 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async editCipher(cipher: CipherView) {
|
||||
if (this.action === 'edit' && this.cipherId === cipher.id) {
|
||||
if (!await this.canNavigateAway('edit', cipher)) {
|
||||
return;
|
||||
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
|
||||
} else if (!await this.passwordReprompt(cipher)) {
|
||||
return;
|
||||
} else if (cipher.reprompt !== CipherRepromptType.None && !await this.passwordRepromptService.showPasswordPrompt()) {
|
||||
}
|
||||
|
||||
await this.editCipherWithoutPasswordPrompt(cipher);
|
||||
}
|
||||
|
||||
async editCipherWithoutPasswordPrompt(cipher: CipherView) {
|
||||
if (!await this.canNavigateAway('edit', cipher)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -342,11 +346,17 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async cloneCipher(cipher: CipherView) {
|
||||
if (this.action === 'clone' && this.cipherId === cipher.id) {
|
||||
if (!await this.canNavigateAway('clone', cipher)) {
|
||||
return;
|
||||
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
|
||||
} else if (!await this.passwordReprompt(cipher)) {
|
||||
return;
|
||||
} else if (cipher.reprompt !== CipherRepromptType.None && !await this.passwordRepromptService.showPasswordPrompt()) {
|
||||
}
|
||||
|
||||
await this.cloneCipherWithoutPasswordPrompt(cipher);
|
||||
}
|
||||
|
||||
async cloneCipherWithoutPasswordPrompt(cipher: CipherView) {
|
||||
if (!await this.canNavigateAway('edit', cipher)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -356,9 +366,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async addCipher(type: CipherType = null) {
|
||||
if (this.action === 'add') {
|
||||
return;
|
||||
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
|
||||
if (!await this.canNavigateAway('add', null)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -680,4 +688,19 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
this.addOrganizationId = null;
|
||||
this.addCollectionIds = null;
|
||||
}
|
||||
|
||||
private async canNavigateAway(action: string, cipher?: CipherView) {
|
||||
// Don't navigate to same route
|
||||
if (this.action === action && (cipher == null || this.cipherId === cipher.id)) {
|
||||
return false;
|
||||
} else if (this.dirtyInput() && await this.wantsToSaveChanges()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async passwordReprompt(cipher: CipherView) {
|
||||
return cipher.reprompt === CipherRepromptType.None || await this.passwordRepromptService.showPasswordPrompt();
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ export class ViewComponent extends BaseViewComponent implements OnChanges {
|
||||
|
||||
onWindowHidden() {
|
||||
this.showPassword = false;
|
||||
this.showCardNumber = false;
|
||||
this.showCardCode = false;
|
||||
if (this.cipher !== null && this.cipher.hasFields) {
|
||||
this.cipher.fields.forEach(field => {
|
||||
|
Loading…
Reference in New Issue
Block a user