1
0
mirror of https://github.com/bitwarden/web synced 2026-01-08 03:23:29 +00:00

Password reprompt (#929)

* Use passwordRepromptService

* Rename passwordPrompt to reprompt. Protect bulk actions

* Change card to hidden, minor refactor.

* Explicit reprompt value check

* Ensure locales are the same on all platforms

* Move showPasswordDialog to platformutils

* Fix sweet alert validation message margin

* Update locale to be the same as browser
This commit is contained in:
Oscar Hinton
2021-05-03 20:55:42 +02:00
committed by GitHub
parent b3a4f833a1
commit b1635debcc
10 changed files with 134 additions and 18 deletions

View File

@@ -11,6 +11,7 @@ import { ToasterService } from 'angular2-toaster';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { EventService } from 'jslib/abstractions/event.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PasswordRepromptService } from 'jslib/abstractions/passwordReprompt.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { SearchService } from 'jslib/abstractions/search.service';
import { TotpService } from 'jslib/abstractions/totp.service';
@@ -18,6 +19,7 @@ import { UserService } from 'jslib/abstractions/user.service';
import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/components/ciphers.component';
import { CipherRepromptType } from 'jslib/enums/cipherRepromptType';
import { CipherType } from 'jslib/enums/cipherType';
import { EventType } from 'jslib/enums/eventType';
@@ -43,7 +45,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
constructor(searchService: SearchService, protected toasterService: ToasterService,
protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService,
protected cipherService: CipherService, protected eventService: EventService,
protected totpService: TotpService, protected userService: UserService) {
protected totpService: TotpService, protected userService: UserService,
protected passwordRepromptService: PasswordRepromptService) {
super(searchService);
this.pageSize = 200;
}
@@ -60,11 +63,17 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
this.platformUtilsService.launchUri(uri);
}
attachments(c: CipherView) {
async attachments(c: CipherView) {
if (!await this.repromptCipher(c)) {
return;
}
this.onAttachmentsClicked.emit(c);
}
share(c: CipherView) {
async share(c: CipherView) {
if (!await this.repromptCipher(c)) {
return;
}
this.onShareClicked.emit(c);
}
@@ -72,11 +81,17 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
this.onCollectionsClicked.emit(c);
}
clone(c: CipherView) {
async clone(c: CipherView) {
if (!await this.repromptCipher(c)) {
return;
}
this.onCloneClicked.emit(c);
}
async delete(c: CipherView): Promise<boolean> {
if (!await this.repromptCipher(c)) {
return;
}
if (this.actionPromise != null) {
return;
}
@@ -121,12 +136,20 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
}
async copy(cipher: CipherView, value: string, typeI18nKey: string, aType: string) {
if (this.passwordRepromptService.protectedFields().includes(aType) && !await this.repromptCipher(cipher)) {
return;
}
if (value == null || aType === 'TOTP' && !this.displayTotpCopyButton(cipher)) {
return;
} else if (value === cipher.login.totp) {
value = await this.totpService.getCode(value);
}
if (!cipher.viewPassword) {
return;
}
this.platformUtilsService.copyToClipboard(value, { window: window });
this.toasterService.popAsync('info', null,
this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey)));
@@ -170,6 +193,12 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
(cipher.organizationUseTotp || this.userHasPremiumAccess);
}
async selectCipher(cipher: CipherView) {
if (await this.repromptCipher(cipher)) {
super.selectCipher(cipher);
}
}
protected deleteCipher(id: string, permanent: boolean) {
return permanent ? this.cipherService.deleteWithServer(id) : this.cipherService.softDeleteWithServer(id);
}
@@ -177,4 +206,8 @@ export class CiphersComponent extends BaseCiphersComponent implements OnDestroy
protected showFixOldAttachments(c: CipherView) {
return c.hasOldAttachments && c.organizationId == null;
}
protected async repromptCipher(c: CipherView) {
return c.reprompt === CipherRepromptType.None || await this.passwordRepromptService.showPasswordPrompt();
}
}