1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 21:33:27 +00:00

[SG-656] Use a captcha bypass during registration (#3531)

* Use a captcha bypass during registration

The trial initiation flow has a registration step that automatically
does a login in the background. This has Captcha problems, namely that
it can spawn two captchas in a row - one during registration and one
during login. This is not ideal UX, so we've added a bypass token that
returns from the registration endpoint that can be used to skip the next
captcha.

* [review] Introduce ICaptcheProtectedResponse
This commit is contained in:
Addison Beck
2022-09-15 16:46:58 -04:00
committed by GitHub
parent 734f052faa
commit 1fcba78905
5 changed files with 31 additions and 9 deletions

View File

@@ -84,6 +84,7 @@ import { VerifyEmailRequest } from "../models/request/verifyEmailRequest";
import { ApiKeyResponse } from "../models/response/apiKeyResponse";
import { AttachmentResponse } from "../models/response/attachmentResponse";
import { AttachmentUploadDataResponse } from "../models/response/attachmentUploadDataResponse";
import { RegisterResponse } from "../models/response/authentication/registerResponse";
import { BillingHistoryResponse } from "../models/response/billingHistoryResponse";
import { BillingPaymentResponse } from "../models/response/billingPaymentResponse";
import { BreachAccountResponse } from "../models/response/breachAccountResponse";
@@ -189,7 +190,7 @@ export abstract class ApiService {
postSecurityStamp: (request: SecretVerificationRequest) => Promise<any>;
getAccountRevisionDate: () => Promise<number>;
postPasswordHint: (request: PasswordHintRequest) => Promise<any>;
postRegister: (request: RegisterRequest) => Promise<any>;
postRegister: (request: RegisterRequest) => Promise<RegisterResponse>;
postPremium: (data: FormData) => Promise<PaymentResponse>;
postIapCheck: (request: IapCheckRequest) => Promise<any>;
postReinstatePremium: () => Promise<any>;

View File

@@ -0,0 +1,3 @@
export interface ICaptchaProtectedResponse {
captchaBypassToken: string;
}

View File

@@ -0,0 +1,12 @@
import { BaseResponse } from "../baseResponse";
import { ICaptchaProtectedResponse } from "./ICaptchaProtectedResponse";
export class RegisterResponse extends BaseResponse implements ICaptchaProtectedResponse {
captchaBypassToken: string;
constructor(response: any) {
super(response);
this.captchaBypassToken = this.getResponseProperty("CaptchaBypassToken");
}
}

View File

@@ -92,6 +92,7 @@ import { VerifyEmailRequest } from "../models/request/verifyEmailRequest";
import { ApiKeyResponse } from "../models/response/apiKeyResponse";
import { AttachmentResponse } from "../models/response/attachmentResponse";
import { AttachmentUploadDataResponse } from "../models/response/attachmentUploadDataResponse";
import { RegisterResponse } from "../models/response/authentication/registerResponse";
import { BillingHistoryResponse } from "../models/response/billingHistoryResponse";
import { BillingPaymentResponse } from "../models/response/billingPaymentResponse";
import { BreachAccountResponse } from "../models/response/breachAccountResponse";
@@ -337,17 +338,18 @@ export class ApiService implements ApiServiceAbstraction {
return this.send("POST", "/accounts/password-hint", request, false, false);
}
postRegister(request: RegisterRequest): Promise<any> {
return this.send(
async postRegister(request: RegisterRequest): Promise<RegisterResponse> {
const r = await this.send(
"POST",
"/accounts/register",
request,
false,
false,
true,
this.platformUtilsService.isDev()
? this.environmentService.getIdentityUrl()
: this.environmentService.getApiUrl()
);
return new RegisterResponse(r);
}
async postPremium(data: FormData): Promise<PaymentResponse> {