1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

Auth/PM-11945 - Registration with Email Verification - Fix Org Sponsored Free Family Plan not working (#11012)

* PM-11945 - AcceptOrg - fix inaccurate comment.

* PM-11945 - Refactor new registration process to pass along orgSponsoredFreeFamilyPlanToken

* PM-11945 - RegistrationFinishComponent - wire up passing of orgSponsoredFreeFamilyPlanToken to submit method

* PM-11945 - Add todo
This commit is contained in:
Jared Snider
2024-09-12 15:24:35 -04:00
committed by GitHub
parent fc2c83f0d3
commit b6cde7e3ef
7 changed files with 69 additions and 14 deletions

View File

@@ -23,6 +23,7 @@ export class DefaultRegistrationFinishService implements RegistrationFinishServi
email: string,
passwordInputResult: PasswordInputResult,
emailVerificationToken?: string,
orgSponsoredFreeFamilyPlanToken?: string,
): Promise<string> {
const [newUserKey, newEncUserKey] = await this.cryptoService.makeUserKey(
passwordInputResult.masterKey,
@@ -35,10 +36,11 @@ export class DefaultRegistrationFinishService implements RegistrationFinishServi
const registerRequest = await this.buildRegisterRequest(
email,
emailVerificationToken,
passwordInputResult,
newEncUserKey.encryptedString,
userAsymmetricKeys,
emailVerificationToken,
orgSponsoredFreeFamilyPlanToken,
);
const capchaBypassToken = await this.accountApiService.registerFinish(registerRequest);
@@ -48,19 +50,19 @@ export class DefaultRegistrationFinishService implements RegistrationFinishServi
protected async buildRegisterRequest(
email: string,
emailVerificationToken: string,
passwordInputResult: PasswordInputResult,
encryptedUserKey: EncryptedString,
userAsymmetricKeys: [string, EncString],
emailVerificationToken?: string,
orgSponsoredFreeFamilyPlanToken?: string, // web only
): Promise<RegisterFinishRequest> {
const userAsymmetricKeysRequest = new KeysRequest(
userAsymmetricKeys[0],
userAsymmetricKeys[1].encryptedString,
);
return new RegisterFinishRequest(
const registerFinishRequest = new RegisterFinishRequest(
email,
emailVerificationToken,
passwordInputResult.masterKeyHash,
passwordInputResult.hint,
encryptedUserKey,
@@ -68,5 +70,11 @@ export class DefaultRegistrationFinishService implements RegistrationFinishServi
passwordInputResult.kdfConfig.kdfType,
passwordInputResult.kdfConfig.iterations,
);
if (emailVerificationToken) {
registerFinishRequest.emailVerificationToken = emailVerificationToken;
}
return registerFinishRequest;
}
}

View File

@@ -33,11 +33,17 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
submitting = false;
email: string;
// Note: this token is the email verification token. It is always supplied as a query param, but
// Note: this token is the email verification token. When it is supplied as a query param,
// it either comes from the email verification email or, if email verification is disabled server side
// via global settings, it comes directly from the registration-start component directly.
// It is not provided when the user is coming from another emailed invite (ex: org invite or enterprise
// org sponsored free family plan invite).
emailVerificationToken: string;
// this token is provided when the user is coming from an emailed invite to
// setup a free family plan sponsored by an organization but they don't have an account yet.
orgSponsoredFreeFamilyPlanToken: string;
masterPasswordPolicyOptions: MasterPasswordPolicyOptions | null = null;
constructor(
@@ -69,6 +75,10 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
if (qParams.token != null) {
this.emailVerificationToken = qParams.token;
}
if (qParams.orgSponsoredFreeFamilyPlanToken != null) {
this.orgSponsoredFreeFamilyPlanToken = qParams.orgSponsoredFreeFamilyPlanToken;
}
}),
switchMap((qParams: Params) => {
if (
@@ -100,6 +110,7 @@ export class RegistrationFinishComponent implements OnInit, OnDestroy {
this.email,
passwordInputResult,
this.emailVerificationToken,
this.orgSponsoredFreeFamilyPlanToken,
);
} catch (e) {
this.validationService.showError(e);

View File

@@ -14,12 +14,14 @@ export abstract class RegistrationFinishService {
*
* @param email The email address of the user.
* @param passwordInputResult The password input result.
* @param emailVerificationToken The optional email verification token. Not present in org invite scenarios.
* @param emailVerificationToken The optional email verification token. Not present in emailed invite scenarios (ex: org invite).
* @param orgSponsoredFreeFamilyPlanToken The optional org sponsored free family plan token.
* Returns a promise which resolves to the captcha bypass token string upon a successful account creation.
*/
abstract finishRegistration(
email: string,
passwordInputResult: PasswordInputResult,
emailVerificationToken?: string,
orgSponsoredFreeFamilyPlanToken?: string,
): Promise<string>;
}