mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +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:
@@ -4,6 +4,11 @@ import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { BaseAcceptComponent } from "../../../common/base.accept.component";
|
||||
|
||||
/*
|
||||
* This component is responsible for handling the acceptance of a families plan sponsorship invite.
|
||||
* "Bitwarden allows all members of Enterprise Organizations to redeem a complimentary Families Plan with their
|
||||
* personal email address." - https://bitwarden.com/learning/free-families-plan-for-enterprise/
|
||||
*/
|
||||
@Component({
|
||||
selector: "app-accept-family-sponsorship",
|
||||
templateUrl: "accept-family-sponsorship.component.html",
|
||||
@@ -26,9 +31,32 @@ export class AcceptFamilySponsorshipComponent extends BaseAcceptComponent {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.router.navigate(["/login"], { queryParams: { email: qParams.email } });
|
||||
} else {
|
||||
// TODO: remove when email verification flag is removed
|
||||
const registerRoute = await firstValueFrom(this.registerRoute$);
|
||||
await this.router.navigate([registerRoute], { queryParams: { email: qParams.email } });
|
||||
// TODO: update logic when email verification flag is removed
|
||||
let queryParams: Params;
|
||||
let registerRoute = await firstValueFrom(this.registerRoute$);
|
||||
if (registerRoute === "/register") {
|
||||
queryParams = {
|
||||
email: qParams.email,
|
||||
};
|
||||
} else if (registerRoute === "/signup") {
|
||||
// We have to override the base component route as we don't need users to
|
||||
// complete email verification if they are coming directly an emailed invite.
|
||||
|
||||
// TODO: in the future, to allow users to enter a name, consider sending all invite users to
|
||||
// start registration page with prefilled email and a named token to be passed directly
|
||||
// along to the finish-signup page without requiring email verification as
|
||||
// we can treat the existence of the token as a form of email verification.
|
||||
|
||||
registerRoute = "/finish-signup";
|
||||
queryParams = {
|
||||
email: qParams.email,
|
||||
orgSponsoredFreeFamilyPlanToken: qParams.token,
|
||||
};
|
||||
}
|
||||
|
||||
await this.router.navigate([registerRoute], {
|
||||
queryParams: queryParams,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,17 +66,18 @@ export class WebRegistrationFinishService
|
||||
// Note: the org invite token and email verification are mutually exclusive. Only one will be present.
|
||||
override async buildRegisterRequest(
|
||||
email: string,
|
||||
emailVerificationToken: string,
|
||||
passwordInputResult: PasswordInputResult,
|
||||
encryptedUserKey: EncryptedString,
|
||||
userAsymmetricKeys: [string, EncString],
|
||||
emailVerificationToken?: string,
|
||||
orgSponsoredFreeFamilyPlanToken?: string,
|
||||
): Promise<RegisterFinishRequest> {
|
||||
const registerRequest = await super.buildRegisterRequest(
|
||||
email,
|
||||
emailVerificationToken,
|
||||
passwordInputResult,
|
||||
encryptedUserKey,
|
||||
userAsymmetricKeys,
|
||||
emailVerificationToken,
|
||||
);
|
||||
|
||||
// web specific logic
|
||||
@@ -89,6 +90,10 @@ export class WebRegistrationFinishService
|
||||
}
|
||||
// Invite is accepted after login (on deep link redirect).
|
||||
|
||||
if (orgSponsoredFreeFamilyPlanToken) {
|
||||
registerRequest.orgSponsoredFreeFamilyPlanToken = orgSponsoredFreeFamilyPlanToken;
|
||||
}
|
||||
|
||||
return registerRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,8 +99,7 @@ export class AcceptOrganizationComponent extends BaseAcceptComponent {
|
||||
email: invite.email,
|
||||
};
|
||||
} else if (registerRoute === "/signup") {
|
||||
// We have to override the base component route b/c it is correct for other components
|
||||
// that extend the base accept comp. We don't need users to complete email verification
|
||||
// We have to override the base component route as we don't need users to complete email verification
|
||||
// if they are coming directly from an emailed org invite.
|
||||
registerRoute = "/finish-signup";
|
||||
queryParams = {
|
||||
|
||||
Reference in New Issue
Block a user