diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 29396a8bcf..6d67047bcb 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -683,6 +683,12 @@ "newAccountCreated": { "message": "Your new account has been created! You may now log in." }, + "newAccountCreated2": { + "message": "Your new account has been created!" + }, + "youHaveBeenLoggedIn": { + "message": "You have been logged in!" + }, "youSuccessfullyLoggedIn": { "message": "You successfully logged in" }, diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index 1bd3718550..5345c6e15a 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -603,6 +603,12 @@ "newAccountCreated": { "message": "Your new account has been created! You may now log in." }, + "newAccountCreated2": { + "message": "Your new account has been created!" + }, + "youHaveBeenLoggedIn": { + "message": "You have been logged in!" + }, "masterPassSent": { "message": "We've sent you an email with your master password hint." }, diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 2583747b4f..6476b70fd0 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -964,6 +964,12 @@ "newAccountCreated": { "message": "Your new account has been created! You may now log in." }, + "newAccountCreated2": { + "message": "Your new account has been created!" + }, + "youHaveBeenLoggedIn": { + "message": "You have been logged in!" + }, "trialAccountCreated": { "message": "Account created successfully." }, diff --git a/libs/auth/src/angular/registration/registration-finish/registration-finish.component.ts b/libs/auth/src/angular/registration/registration-finish/registration-finish.component.ts index 03886fe88d..3c7e31b5de 100644 --- a/libs/auth/src/angular/registration/registration-finish/registration-finish.component.ts +++ b/libs/auth/src/angular/registration/registration-finish/registration-finish.component.ts @@ -10,9 +10,11 @@ import { RegisterVerificationEmailClickedRequest } from "@bitwarden/common/auth/ import { HttpStatusCode } from "@bitwarden/common/enums"; import { ErrorResponse } from "@bitwarden/common/models/response/error.response"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service"; import { ToastService } from "@bitwarden/components"; +import { LoginStrategyServiceAbstraction, PasswordLoginCredentials } from "../../../common"; import { InputPasswordComponent } from "../../input-password/input-password.component"; import { PasswordInputResult } from "../../input-password/password-input-result"; @@ -46,6 +48,8 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy { private registrationFinishService: RegistrationFinishService, private validationService: ValidationService, private accountApiService: AccountApiService, + private loginStrategyService: LoginStrategyServiceAbstraction, + private logService: LogService, ) {} async ngOnInit() { @@ -90,8 +94,9 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy { async handlePasswordFormSubmit(passwordInputResult: PasswordInputResult) { this.submitting = true; + let captchaBypassToken: string = null; try { - await this.registrationFinishService.finishRegistration( + captchaBypassToken = await this.registrationFinishService.finishRegistration( this.email, passwordInputResult, this.emailVerificationToken, @@ -102,14 +107,37 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy { return; } + // Show acct created toast this.toastService.showToast({ variant: "success", title: null, - message: this.i18nService.t("newAccountCreated"), + message: this.i18nService.t("newAccountCreated2"), }); + // login with the new account + try { + const credentials = new PasswordLoginCredentials( + this.email, + passwordInputResult.password, + captchaBypassToken, + null, + ); + + await this.loginStrategyService.logIn(credentials); + + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("youHaveBeenLoggedIn"), + }); + + await this.router.navigate(["/vault"]); + } catch (e) { + // If login errors, redirect to login page per product. Don't show error + this.logService.error("Error logging in after registration: ", e.message); + await this.router.navigate(["/login"], { queryParams: { email: this.email } }); + } this.submitting = false; - await this.router.navigate(["/login"], { queryParams: { email: this.email } }); } private async registerVerificationEmailClicked(email: string, emailVerificationToken: string) {