Auth/PM-11318 - Registration With Email Verification - Login After Registration (#10783)
* PM-11318 - Registration Finish - Log user in after registration * PM-11318 - Adjust registration and login message to be one msg * PM-11318 - RegistrationFinish - Adjust messaging based on product feedback. * PM-11318 - RegistrationFinishComp - Tweak redirect and error logic.
This commit is contained in:
parent
d4b984f907
commit
0a0cbde5b3
|
@ -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"
|
||||
},
|
||||
|
|
|
@ -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."
|
||||
},
|
||||
|
|
|
@ -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."
|
||||
},
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue