mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-11 10:10:25 +01:00
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": {
|
"newAccountCreated": {
|
||||||
"message": "Your new account has been created! You may now log in."
|
"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": {
|
"youSuccessfullyLoggedIn": {
|
||||||
"message": "You successfully logged in"
|
"message": "You successfully logged in"
|
||||||
},
|
},
|
||||||
|
@ -603,6 +603,12 @@
|
|||||||
"newAccountCreated": {
|
"newAccountCreated": {
|
||||||
"message": "Your new account has been created! You may now log in."
|
"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": {
|
"masterPassSent": {
|
||||||
"message": "We've sent you an email with your master password hint."
|
"message": "We've sent you an email with your master password hint."
|
||||||
},
|
},
|
||||||
|
@ -964,6 +964,12 @@
|
|||||||
"newAccountCreated": {
|
"newAccountCreated": {
|
||||||
"message": "Your new account has been created! You may now log in."
|
"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": {
|
"trialAccountCreated": {
|
||||||
"message": "Account created successfully."
|
"message": "Account created successfully."
|
||||||
},
|
},
|
||||||
|
@ -10,9 +10,11 @@ import { RegisterVerificationEmailClickedRequest } from "@bitwarden/common/auth/
|
|||||||
import { HttpStatusCode } from "@bitwarden/common/enums";
|
import { HttpStatusCode } from "@bitwarden/common/enums";
|
||||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||||
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 { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { ToastService } from "@bitwarden/components";
|
import { ToastService } from "@bitwarden/components";
|
||||||
|
|
||||||
|
import { LoginStrategyServiceAbstraction, PasswordLoginCredentials } from "../../../common";
|
||||||
import { InputPasswordComponent } from "../../input-password/input-password.component";
|
import { InputPasswordComponent } from "../../input-password/input-password.component";
|
||||||
import { PasswordInputResult } from "../../input-password/password-input-result";
|
import { PasswordInputResult } from "../../input-password/password-input-result";
|
||||||
|
|
||||||
@ -46,6 +48,8 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
|
|||||||
private registrationFinishService: RegistrationFinishService,
|
private registrationFinishService: RegistrationFinishService,
|
||||||
private validationService: ValidationService,
|
private validationService: ValidationService,
|
||||||
private accountApiService: AccountApiService,
|
private accountApiService: AccountApiService,
|
||||||
|
private loginStrategyService: LoginStrategyServiceAbstraction,
|
||||||
|
private logService: LogService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@ -90,8 +94,9 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
async handlePasswordFormSubmit(passwordInputResult: PasswordInputResult) {
|
async handlePasswordFormSubmit(passwordInputResult: PasswordInputResult) {
|
||||||
this.submitting = true;
|
this.submitting = true;
|
||||||
|
let captchaBypassToken: string = null;
|
||||||
try {
|
try {
|
||||||
await this.registrationFinishService.finishRegistration(
|
captchaBypassToken = await this.registrationFinishService.finishRegistration(
|
||||||
this.email,
|
this.email,
|
||||||
passwordInputResult,
|
passwordInputResult,
|
||||||
this.emailVerificationToken,
|
this.emailVerificationToken,
|
||||||
@ -102,14 +107,37 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show acct created toast
|
||||||
this.toastService.showToast({
|
this.toastService.showToast({
|
||||||
variant: "success",
|
variant: "success",
|
||||||
title: null,
|
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;
|
this.submitting = false;
|
||||||
await this.router.navigate(["/login"], { queryParams: { email: this.email } });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async registerVerificationEmailClicked(email: string, emailVerificationToken: string) {
|
private async registerVerificationEmailClicked(email: string, emailVerificationToken: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user