Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM 4972] change kdf confirmation component migration #8489

Merged
merged 5 commits into from May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,50 +1,33 @@
<bit-dialog>
<span bitDialogTitle>
{{ "changeKdf" | i18n }}
</span>
<form [formGroup]="form" [bitSubmit]="submit" autocomplete="off">
<bit-dialog>
<span bitDialogTitle>
{{ "changeKdf" | i18n }}
</span>

<span bitDialogContent>
<bit-callout type="warning">{{ "changeKdfLoggedOutWarning" | i18n }}</bit-callout>
<form
id="form"
[formGroup]="form"
(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
type="button"
bitSuffix
bitIconButton
bitPasswordInputToggle
[(toggled)]="showPassword"
></button
><bit-hint>
{{ "confirmIdentity" | i18n }}
</bit-hint></bit-form-field
>
</div>
</div>
</form>
</span>
<ng-container bitDialogFooter>
<button bitButton buttonType="primary" type="submit" [loading]="loading" form="form">
<span>{{ "changeKdf" | i18n }}</span>
</button>
<button bitButton buttonType="secondary" type="button" bitDialogClose>
{{ "cancel" | i18n }}
</button>
</ng-container>
</bit-dialog>
<span bitDialogContent>
<bit-callout type="warning">{{ "changeKdfLoggedOutWarning" | i18n }}</bit-callout>
<bit-form-field>
<bit-label>{{ "masterPass" | i18n }}</bit-label>
<input bitInput type="password" formControlName="masterPassword" appAutofocus />
<button
type="button"
bitIconButton
bitSuffix
bitPasswordInputToggle
[(toggled)]="showPassword"
></button>
<bit-hint>
{{ "confirmIdentity" | i18n }}
</bit-hint></bit-form-field
>
</span>
<ng-container bitDialogFooter>
<button bitButton buttonType="primary" type="submit" bitFormButton>
<span>{{ "changeKdf" | i18n }}</span>
</button>
<button bitButton buttonType="secondary" type="button" bitFormButton bitDialogClose>
{{ "cancel" | i18n }}
</button>
</ng-container>
</bit-dialog>
</form>
Expand Up @@ -7,7 +7,6 @@
import { KdfRequest } from "@bitwarden/common/models/request/kdf.request";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.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 { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
Expand All @@ -26,7 +25,6 @@
});
showPassword = false;
masterPassword: string;
formPromise: Promise<any>;
loading = false;

constructor(
Expand All @@ -36,32 +34,24 @@
private cryptoService: CryptoService,
private messagingService: MessagingService,
private stateService: StateService,
private logService: LogService,
@Inject(DIALOG_DATA) params: { kdf: KdfType; kdfConfig: KdfConfig },
) {
this.kdf = params.kdf;
this.kdfConfig = params.kdfConfig;
this.masterPassword = null;
}

async submit() {
submit = async () => {

Check warning on line 44 in apps/web/src/app/auth/settings/security/change-kdf/change-kdf-confirmation.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/security/change-kdf/change-kdf-confirmation.component.ts#L44

Added line #L44 was not covered by tests
this.loading = true;

try {
this.formPromise = this.makeKeyAndSaveAsync();
await this.formPromise;
this.platformUtilsService.showToast(
"success",
this.i18nService.t("encKeySettingsChanged"),
this.i18nService.t("logBackIn"),
);
this.messagingService.send("logout");
} catch (e) {
this.logService.error(e);
} finally {
this.loading = false;
}
}
await this.makeKeyAndSaveAsync();
this.platformUtilsService.showToast(

Check warning on line 47 in apps/web/src/app/auth/settings/security/change-kdf/change-kdf-confirmation.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/security/change-kdf/change-kdf-confirmation.component.ts#L46-L47

Added lines #L46 - L47 were not covered by tests
"success",
this.i18nService.t("encKeySettingsChanged"),
this.i18nService.t("logBackIn"),
);
this.messagingService.send("logout");
this.loading = false;

Check warning on line 53 in apps/web/src/app/auth/settings/security/change-kdf/change-kdf-confirmation.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/auth/settings/security/change-kdf/change-kdf-confirmation.component.ts#L52-L53

Added lines #L52 - L53 were not covered by tests
};

private async makeKeyAndSaveAsync() {
const masterPassword = this.form.value.masterPassword;
Expand Down