Skip to content

Commit 8cda49f

Browse files
committed
MOBILE-4362 signup: Display required error in recaptcha
1 parent 935da86 commit 8cda49f

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/core/components/recaptcha/core-recaptcha.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
<ion-item *ngIf="model[modelValueName]">
88
<ion-label color="success">{{ 'core.answered' | translate }}</ion-label>
99
</ion-item>
10-
<ion-item *ngIf="expired" class="ion-text-wrap">
10+
<ion-item *ngIf="expired" class="ion-text-wrap core-input-error">
1111
<ion-label color="danger">{{ 'core.login.recaptchaexpired' | translate }}</ion-label>
1212
</ion-item>
13+
<ion-item *ngIf="showRequiredError && !model[modelValueName] && !expired" class="ion-text-wrap core-input-error">
14+
<ion-label color="danger">{{ 'core.required' | translate }}</ion-label>
15+
</ion-item>
1316
</div>

src/core/components/recaptcha/recaptcha.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class CoreRecaptchaComponent implements OnInit {
3232
@Input() publicKey?: string; // The site public key.
3333
@Input() modelValueName = 'recaptcharesponse'; // Name of the model property where to store the response.
3434
@Input() siteUrl = ''; // The site URL. If not defined, current site.
35+
@Input() showRequiredError = false; // Whether to display the required error if recaptcha hasn't been answered.
3536

3637
expired = false;
3738

src/core/features/login/pages/email-signup/email-signup.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ <h2>{{ 'core.login.supplyinfo' | translate }}</h2>
186186
<h2><span [core-mark-required]="true">{{ 'core.login.security_question' | translate }}</span></h2>
187187
</ion-label>
188188
</ion-item-divider>
189-
<core-recaptcha [publicKey]="settings.recaptchapublickey" [model]="captcha" [siteUrl]="siteUrl"></core-recaptcha>
189+
<core-recaptcha [publicKey]="settings.recaptchapublickey" [model]="captcha" [siteUrl]="siteUrl"
190+
[showRequiredError]="formSubmitClicked"></core-recaptcha>
190191
</ng-container>
191192

192193
<!-- Site policy (if any). -->

src/core/features/login/pages/email-signup/email-signup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export class CoreLoginEmailSignupPage implements OnInit {
6060
settingsLoaded = false;
6161
allRequiredSupported = true;
6262
signupUrl?: string;
63+
formSubmitClicked = false;
6364
captcha = {
6465
recaptcharesponse: '',
6566
};
@@ -265,6 +266,8 @@ export class CoreLoginEmailSignupPage implements OnInit {
265266
e.preventDefault();
266267
e.stopPropagation();
267268

269+
this.formSubmitClicked = true;
270+
268271
if (!this.signupForm.valid || (this.settings?.recaptchapublickey && !this.captcha.recaptcharesponse)) {
269272
// Form not valid. Mark all controls as dirty to display errors.
270273
for (const name in this.signupForm.controls) {

0 commit comments

Comments
 (0)