mirror of
https://github.com/bitwarden/browser
synced 2026-01-03 17:13:47 +00:00
Feature/use hcaptcha on register if bot (#434)
* Parse captcha required from error messages CaptchaProtectedAttribute produces an error with captcha information. We want to parse that data out to make it easily accessible to components * Don't show error on catpcha The component should hande this situation. * Add captchaResponse to captcha protected api endpoints * Extract captcha logic to abstract base class * Add captcha to register * linter fixes * Make sure to log Captcha required responses * Match file naming convention * Separate import into logical groups by folder * PR review
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import { Utils } from '../../misc/utils';
|
||||
|
||||
import { BaseResponse } from './baseResponse';
|
||||
|
||||
export class ErrorResponse extends BaseResponse {
|
||||
message: string;
|
||||
validationErrors: { [key: string]: string[]; };
|
||||
statusCode: number;
|
||||
captchaRequired: boolean;
|
||||
captchaSiteKey: string;
|
||||
|
||||
constructor(response: any, status: number, identityResponse?: boolean) {
|
||||
super(response);
|
||||
@@ -20,6 +24,8 @@ export class ErrorResponse extends BaseResponse {
|
||||
if (errorModel) {
|
||||
this.message = this.getResponseProperty('Message', errorModel);
|
||||
this.validationErrors = this.getResponseProperty('ValidationErrors', errorModel);
|
||||
this.captchaSiteKey = this.validationErrors?.HCaptcha_SiteKey?.[0];
|
||||
this.captchaRequired = !Utils.isNullOrWhitespace(this.captchaSiteKey);
|
||||
} else {
|
||||
if (status === 429) {
|
||||
this.message = 'Rate limit exceeded. Try again later.';
|
||||
|
||||
Reference in New Issue
Block a user