mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
change kdf confirmation component migration (#8489)
Change kdf configuration component migration
This commit is contained in:
@@ -1,50 +1,33 @@
|
|||||||
<bit-dialog>
|
<form [formGroup]="form" [bitSubmit]="submit" autocomplete="off">
|
||||||
|
<bit-dialog>
|
||||||
<span bitDialogTitle>
|
<span bitDialogTitle>
|
||||||
{{ "changeKdf" | i18n }}
|
{{ "changeKdf" | i18n }}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span bitDialogContent>
|
<span bitDialogContent>
|
||||||
<bit-callout type="warning">{{ "kdfSettingsChangeLogoutWarning" | i18n }}</bit-callout>
|
<bit-callout type="warning">{{ "kdfSettingsChangeLogoutWarning" | i18n }}</bit-callout>
|
||||||
<form
|
<bit-form-field>
|
||||||
id="form"
|
<bit-label>{{ "masterPass" | i18n }}</bit-label>
|
||||||
[formGroup]="form"
|
<input bitInput type="password" formControlName="masterPassword" appAutofocus />
|
||||||
(ngSubmit)="submit()"
|
|
||||||
[appApiAction]="formPromise"
|
|
||||||
ngNativeValidate
|
|
||||||
autocomplete="off"
|
|
||||||
>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<bit-form-field class="tw-mb-1"
|
|
||||||
><bit-label>{{ "masterPass" | i18n }}</bit-label>
|
|
||||||
<input
|
|
||||||
bitInput
|
|
||||||
type="password"
|
|
||||||
required
|
|
||||||
formControlName="masterPassword"
|
|
||||||
appAutofocus
|
|
||||||
/>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
bitSuffix
|
|
||||||
bitIconButton
|
bitIconButton
|
||||||
|
bitSuffix
|
||||||
bitPasswordInputToggle
|
bitPasswordInputToggle
|
||||||
[(toggled)]="showPassword"
|
[(toggled)]="showPassword"
|
||||||
></button
|
></button>
|
||||||
><bit-hint>
|
<bit-hint>
|
||||||
{{ "confirmIdentity" | i18n }}
|
{{ "confirmIdentity" | i18n }}
|
||||||
</bit-hint></bit-form-field
|
</bit-hint></bit-form-field
|
||||||
>
|
>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</span>
|
</span>
|
||||||
<ng-container bitDialogFooter>
|
<ng-container bitDialogFooter>
|
||||||
<button bitButton buttonType="primary" type="submit" [loading]="loading" form="form">
|
<button bitButton buttonType="primary" type="submit" bitFormButton>
|
||||||
<span>{{ "changeKdf" | i18n }}</span>
|
<span>{{ "changeKdf" | i18n }}</span>
|
||||||
</button>
|
</button>
|
||||||
<button bitButton buttonType="secondary" type="button" bitDialogClose>
|
<button bitButton buttonType="secondary" type="button" bitFormButton bitDialogClose>
|
||||||
{{ "cancel" | i18n }}
|
{{ "cancel" | i18n }}
|
||||||
</button>
|
</button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</bit-dialog>
|
</bit-dialog>
|
||||||
|
</form>
|
||||||
|
|||||||
@@ -5,12 +5,10 @@ import { firstValueFrom, map } from "rxjs";
|
|||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config.service";
|
|
||||||
import { KdfConfig } from "@bitwarden/common/auth/models/domain/kdf-config";
|
import { KdfConfig } from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||||
import { KdfRequest } from "@bitwarden/common/models/request/kdf.request";
|
import { KdfRequest } from "@bitwarden/common/models/request/kdf.request";
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { KdfType } from "@bitwarden/common/platform/enums";
|
import { KdfType } from "@bitwarden/common/platform/enums";
|
||||||
@@ -27,7 +25,6 @@ export class ChangeKdfConfirmationComponent {
|
|||||||
});
|
});
|
||||||
showPassword = false;
|
showPassword = false;
|
||||||
masterPassword: string;
|
masterPassword: string;
|
||||||
formPromise: Promise<any>;
|
|
||||||
loading = false;
|
loading = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -36,33 +33,24 @@ export class ChangeKdfConfirmationComponent {
|
|||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private cryptoService: CryptoService,
|
private cryptoService: CryptoService,
|
||||||
private messagingService: MessagingService,
|
private messagingService: MessagingService,
|
||||||
|
@Inject(DIALOG_DATA) params: { kdf: KdfType; kdfConfig: KdfConfig },
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
private logService: LogService,
|
|
||||||
private kdfConfigService: KdfConfigService,
|
|
||||||
@Inject(DIALOG_DATA) params: { kdfConfig: KdfConfig },
|
|
||||||
) {
|
) {
|
||||||
this.kdfConfig = params.kdfConfig;
|
this.kdfConfig = params.kdfConfig;
|
||||||
this.masterPassword = null;
|
this.masterPassword = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
submit = async () => {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
await this.makeKeyAndSaveAsync();
|
||||||
try {
|
|
||||||
this.formPromise = this.makeKeyAndSaveAsync();
|
|
||||||
await this.formPromise;
|
|
||||||
this.platformUtilsService.showToast(
|
this.platformUtilsService.showToast(
|
||||||
"success",
|
"success",
|
||||||
this.i18nService.t("encKeySettingsChanged"),
|
this.i18nService.t("encKeySettingsChanged"),
|
||||||
this.i18nService.t("logBackIn"),
|
this.i18nService.t("logBackIn"),
|
||||||
);
|
);
|
||||||
this.messagingService.send("logout");
|
this.messagingService.send("logout");
|
||||||
} catch (e) {
|
|
||||||
this.logService.error(e);
|
|
||||||
} finally {
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
private async makeKeyAndSaveAsync() {
|
private async makeKeyAndSaveAsync() {
|
||||||
const masterPassword = this.form.value.masterPassword;
|
const masterPassword = this.form.value.masterPassword;
|
||||||
|
|||||||
Reference in New Issue
Block a user