forked from CIT/Vmeda.Online
		
	MOBILE-3320 signup: Expire recaptcha if error returned
This commit is contained in:
		
							parent
							
								
									c15d5de95d
								
							
						
					
					
						commit
						ae7b380a72
					
				@ -7,7 +7,7 @@
 | 
			
		||||
    <ion-item *ngIf="model[modelValueName]">
 | 
			
		||||
        <ion-label color="success">{{ 'core.answered' | translate }}</ion-label>
 | 
			
		||||
    </ion-item>
 | 
			
		||||
    <ion-item *ngIf="expired">
 | 
			
		||||
    <ion-item *ngIf="expired" class="ion-text-wrap">
 | 
			
		||||
        <ion-label color="danger">{{ 'core.login.recaptchaexpired' | translate }}</ion-label>
 | 
			
		||||
    </ion-item>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
@ -87,8 +87,7 @@ export class CoreRecaptchaComponent implements OnInit {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (event.data.action == 'expired') {
 | 
			
		||||
                this.expired = true;
 | 
			
		||||
                this.model![this.modelValueName] = '';
 | 
			
		||||
                this.expireRecaptchaAnswer();
 | 
			
		||||
            } else if (event.data.action == 'callback') {
 | 
			
		||||
                this.expired = false;
 | 
			
		||||
                this.model![this.modelValueName] = event.data.value;
 | 
			
		||||
@ -101,4 +100,12 @@ export class CoreRecaptchaComponent implements OnInit {
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Expire the recaptcha answer.
 | 
			
		||||
     */
 | 
			
		||||
    expireRecaptchaAnswer(): void {
 | 
			
		||||
        this.expired = true;
 | 
			
		||||
        this.model![this.modelValueName] = '';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -33,6 +33,7 @@ import {
 | 
			
		||||
} from '@features/login/services/login-helper';
 | 
			
		||||
import { CoreNavigator } from '@services/navigator';
 | 
			
		||||
import { CoreForms } from '@singletons/form';
 | 
			
		||||
import { CoreRecaptchaComponent } from '@components/recaptcha/recaptcha';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Page to signup using email.
 | 
			
		||||
@ -45,6 +46,7 @@ import { CoreForms } from '@singletons/form';
 | 
			
		||||
export class CoreLoginEmailSignupPage implements OnInit {
 | 
			
		||||
 | 
			
		||||
    @ViewChild(IonContent) content?: IonContent;
 | 
			
		||||
    @ViewChild(CoreRecaptchaComponent) recaptchaComponent?: CoreRecaptchaComponent;
 | 
			
		||||
    @ViewChild('ageForm') ageFormElement?: ElementRef;
 | 
			
		||||
    @ViewChild('signupFormEl') signupFormElement?: ElementRef;
 | 
			
		||||
 | 
			
		||||
@ -341,9 +343,12 @@ export class CoreLoginEmailSignupPage implements OnInit {
 | 
			
		||||
                CoreDomUtils.showAlert(Translate.instant('core.success'), message);
 | 
			
		||||
                CoreNavigator.back();
 | 
			
		||||
            } else {
 | 
			
		||||
                if (result.warnings && result.warnings.length) {
 | 
			
		||||
                    let error = result.warnings[0].message;
 | 
			
		||||
                    if (error == 'incorrect-captcha-sol') {
 | 
			
		||||
                this.recaptchaComponent?.expireRecaptchaAnswer();
 | 
			
		||||
 | 
			
		||||
                const warning = result.warnings?.[0];
 | 
			
		||||
                if (warning) {
 | 
			
		||||
                    let error = warning.message;
 | 
			
		||||
                    if (error == 'incorrect-captcha-sol' || (!error && warning.item == 'recaptcharesponse')) {
 | 
			
		||||
                        error = Translate.instant('core.login.recaptchaincorrect');
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user