mirror of
https://github.com/bitwarden/browser
synced 2026-02-10 05:30:01 +00:00
Registration on change password
This commit is contained in:
@@ -12,6 +12,7 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
||||
import { UserVerificationService } from "@bitwarden/common/auth/abstractions/user-verification/user-verification.service.abstraction";
|
||||
import { PasswordRequest } from "@bitwarden/common/auth/models/request/password.request";
|
||||
import { OpaqueService } from "@bitwarden/common/auth/opaque/opaque.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
||||
@@ -59,6 +60,7 @@ export class ChangePasswordComponent
|
||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
||||
accountService: AccountService,
|
||||
toastService: ToastService,
|
||||
private opaqueService: OpaqueService,
|
||||
) {
|
||||
super(
|
||||
i18nService,
|
||||
@@ -213,6 +215,7 @@ export class ChangePasswordComponent
|
||||
|
||||
try {
|
||||
if (this.rotateUserKey) {
|
||||
throw new Error("Userkey rotation not supported");
|
||||
this.formPromise = this.apiService.postPassword(request).then(async () => {
|
||||
// we need to save this for local masterkey verification during rotation
|
||||
await this.masterPasswordService.setMasterKeyHash(newLocalKeyHash, userId as UserId);
|
||||
@@ -223,6 +226,7 @@ export class ChangePasswordComponent
|
||||
this.formPromise = this.apiService.postPassword(request);
|
||||
}
|
||||
|
||||
await this.opaqueService.Register(this.masterPassword, newUserKey[0]);
|
||||
await this.formPromise;
|
||||
|
||||
this.toastService.showToast({
|
||||
@@ -230,7 +234,7 @@ export class ChangePasswordComponent
|
||||
title: this.i18nService.t("masterPasswordChanged"),
|
||||
message: this.i18nService.t("logBackIn"),
|
||||
});
|
||||
this.messagingService.send("logout");
|
||||
//this.messagingService.send("logout");
|
||||
} catch {
|
||||
this.toastService.showToast({
|
||||
variant: "error",
|
||||
|
||||
@@ -104,6 +104,10 @@ import { UserVerificationService as UserVerificationServiceAbstraction } from "@
|
||||
import { WebAuthnLoginApiServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login-api.service.abstraction";
|
||||
import { WebAuthnLoginPrfKeyServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login-prf-key.service.abstraction";
|
||||
import { WebAuthnLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login.service.abstraction";
|
||||
import { DefaultOpaqueApiService } from "@bitwarden/common/auth/opaque/default-opaque-api.service";
|
||||
import { DefaultOpaqueService } from "@bitwarden/common/auth/opaque/default-opaque.service";
|
||||
import { OpaqueApiService } from "@bitwarden/common/auth/opaque/opaque-api.service";
|
||||
import { OpaqueService } from "@bitwarden/common/auth/opaque/opaque.service";
|
||||
import { AccountApiServiceImplementation } from "@bitwarden/common/auth/services/account-api.service";
|
||||
import { AccountServiceImplementation } from "@bitwarden/common/auth/services/account.service";
|
||||
import { AnonymousHubService } from "@bitwarden/common/auth/services/anonymous-hub.service";
|
||||
@@ -1475,6 +1479,16 @@ const safeProviders: SafeProvider[] = [
|
||||
ToastService,
|
||||
],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: OpaqueApiService,
|
||||
useClass: DefaultOpaqueApiService,
|
||||
deps: [ApiServiceAbstraction, EnvironmentService],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: OpaqueService,
|
||||
useClass: DefaultOpaqueService,
|
||||
deps: [OpaqueApiService, SdkService],
|
||||
}),
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
|
||||
@@ -21,9 +21,9 @@ export class DefaultOpaqueApiService implements OpaqueApiService {
|
||||
const env = await firstValueFrom(this.environmentService.environment$);
|
||||
const response = await this.apiService.send(
|
||||
"POST",
|
||||
`/opaque/registration-start`,
|
||||
`/opaque/start-registration`,
|
||||
request,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
env.getApiUrl(),
|
||||
);
|
||||
@@ -37,9 +37,9 @@ export class DefaultOpaqueApiService implements OpaqueApiService {
|
||||
const env = await firstValueFrom(this.environmentService.environment$);
|
||||
const response = await this.apiService.send(
|
||||
"POST",
|
||||
`/opaque/${credentialId}registration-start`,
|
||||
`/opaque/finish-registration`,
|
||||
request,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
env.getApiUrl(),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OpaqueSessionId as OpaqueSessionId } from "../../types/guid";
|
||||
import { OpaqueSessionId } from "../../types/guid";
|
||||
|
||||
import { RegistrationFinishRequest } from "./models/registration-finish.request";
|
||||
import { RegistrationFinishResponse } from "./models/registration-finish.response";
|
||||
|
||||
Reference in New Issue
Block a user