1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 08:13:42 +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:
Matt Gibson
2021-07-22 12:28:45 -05:00
committed by GitHub
parent ea0c8267d4
commit e9d9cd0182
8 changed files with 117 additions and 64 deletions

View File

@@ -4,6 +4,9 @@ import {
Input,
OnChanges,
} from '@angular/core';
import { LogService } from 'jslib-common/abstractions/log.service';
import { ErrorResponse } from 'jslib-common/models/response';
import { ValidationService } from '../services/validation.service';
@@ -13,7 +16,8 @@ import { ValidationService } from '../services/validation.service';
export class ApiActionDirective implements OnChanges {
@Input() appApiAction: Promise<any>;
constructor(private el: ElementRef, private validationService: ValidationService) { }
constructor(private el: ElementRef, private validationService: ValidationService,
private logService: LogService) { }
ngOnChanges(changes: any) {
if (this.appApiAction == null || this.appApiAction.then == null) {
@@ -26,6 +30,11 @@ export class ApiActionDirective implements OnChanges {
this.el.nativeElement.loading = false;
}, (e: any) => {
this.el.nativeElement.loading = false;
if (e instanceof ErrorResponse && (e as ErrorResponse).captchaRequired) {
this.logService.error('Captcha required error response: ' + e.getSingleMessage());
return;
}
this.validationService.showError(e);
});
}