Merge pull request #1311 from dpalou/MOBILE-2415
MOBILE-2415 signup: Support age verification formmain
commit
4c222b79af
|
@ -14,7 +14,7 @@
|
|||
<!-- If no sitename show big siteurl. -->
|
||||
<p *ngIf="!siteName" padding class="item-heading core-siteurl">{{siteUrl}}</p>
|
||||
<!-- If sitename, show big sitename and small siteurl. -->
|
||||
<p *ngIf="siteName" padding class="item-heading core-sitename">{{siteName}}</p>
|
||||
<p *ngIf="siteName" padding class="item-heading core-sitename"><core-format-text [text]="siteName"></core-format-text></p>
|
||||
<p *ngIf="siteName" class="core-siteurl">{{siteUrl}}</p>
|
||||
</div>
|
||||
<form ion-list [formGroup]="credForm" (ngSubmit)="login()">
|
||||
|
|
|
@ -10,17 +10,49 @@
|
|||
</ion-navbar>
|
||||
</ion-header>
|
||||
<ion-content>
|
||||
<ion-refresher [enabled]="settingsLoaded" (ionRefresh)="refreshSettings($event)">
|
||||
<ion-refresher [enabled]="settingsLoaded && !isMinor" (ionRefresh)="refreshSettings($event)">
|
||||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||
</ion-refresher>
|
||||
|
||||
<core-loading [hideUntil]="settingsLoaded">
|
||||
<form ion-list *ngIf="settingsLoaded && settings" [formGroup]="signupForm" (ngSubmit)="create()" class="list list-inset">
|
||||
<core-loading [hideUntil]="settingsLoaded" *ngIf="!isMinor">
|
||||
|
||||
<!-- Age verification. -->
|
||||
<form ion-list *ngIf="settingsLoaded && settings && ageDigitalConsentVerification" [formGroup]="ageVerificationForm" (ngSubmit)="verifyAge()">
|
||||
<ion-item-divider color="light" text-wrap>
|
||||
<p class="item-heading">{{ 'core.agelocationverification' | translate }}</p>
|
||||
</ion-item-divider>
|
||||
|
||||
<ion-item text-wrap>
|
||||
<ion-label stacked core-mark-required="true">{{ 'core.whatisyourage' | translate }}</ion-label>
|
||||
<ion-input type="number" name="age" placeholder="0" formControlName="age" autocapitalize="none" autocorrect="off"></ion-input>
|
||||
</ion-item>
|
||||
|
||||
<ion-item text-wrap>
|
||||
<ion-label stacked core-mark-required="true">{{ 'core.wheredoyoulive' | translate }}</ion-label>
|
||||
<ion-select name="country" formControlName="country" interface="popover">
|
||||
<ion-option value="">{{ 'core.login.selectacountry' | translate }}</ion-option>
|
||||
<ion-option *ngFor="let key of countriesKeys" [value]="key">{{countries[key]}}</ion-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
<!-- Submit button. -->
|
||||
<ion-item padding>
|
||||
<button ion-button block type="submit" [disabled]="!ageVerificationForm.valid">{{ 'core.proceed' | translate }}</button>
|
||||
</ion-item>
|
||||
|
||||
<ion-item text-wrap>
|
||||
<p class="item-heading">{{ 'core.whyisthisrequired' | translate }}</p>
|
||||
<p>{{ 'core.explanationdigitalminor' | translate }}</p>
|
||||
</ion-item>
|
||||
</form>
|
||||
|
||||
<!-- Signup form. -->
|
||||
<form ion-list *ngIf="settingsLoaded && settings && !ageDigitalConsentVerification" [formGroup]="signupForm" (ngSubmit)="create()">
|
||||
<ion-item text-wrap text-center>
|
||||
<!-- If no sitename show big siteurl. -->
|
||||
<p *ngIf="!siteName" padding class="item-heading">{{siteUrl}}</p>
|
||||
<!-- If sitename, show big sitename and small siteurl. -->
|
||||
<p *ngIf="siteName" padding class="item-heading">{{siteName}}</p>
|
||||
<p *ngIf="siteName" padding class="item-heading"><core-format-text [text]="siteName"></core-format-text></p>
|
||||
<p *ngIf="siteName">{{siteUrl}}</p>
|
||||
</ion-item>
|
||||
|
||||
|
@ -108,4 +140,21 @@
|
|||
</ion-item>
|
||||
</form>
|
||||
</core-loading>
|
||||
|
||||
<ion-list *ngIf="isMinor">
|
||||
<ion-item-divider color="light" text-wrap>
|
||||
<p *ngIf="siteName" class="item-heading padding"><core-format-text [text]="siteName"></core-format-text></p>
|
||||
</ion-item-divider>
|
||||
<ion-item text-wrap>
|
||||
<p class="item-heading">{{ 'core.considereddigitalminor' | translate }}</p>
|
||||
<p>{{ 'core.digitalminor_desc' | translate }}</p>
|
||||
<p *ngIf="supportName">{{ supportName }}</p>
|
||||
<p *ngIf="supportEmail">{{ supportEmail }}</p>
|
||||
<div padding *ngIf="!supportName && !supportEmail">
|
||||
<button ion-button block (click)="showContactOnSite()">
|
||||
{{ 'core.openinbrowser' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreTextUtilsProvider } from '@providers/utils/text';
|
|||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||
import { CoreWSProvider } from '@providers/ws';
|
||||
import { CoreLoginHelperProvider } from '../../providers/helper';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
|
||||
import { CoreUserProfileFieldDelegate } from '@core/user/providers/user-profile-field-delegate';
|
||||
|
||||
/**
|
||||
|
@ -34,6 +34,7 @@ import { CoreUserProfileFieldDelegate } from '@core/user/providers/user-profile-
|
|||
})
|
||||
export class CoreLoginEmailSignupPage {
|
||||
@ViewChild(Content) content: Content;
|
||||
|
||||
signupForm: FormGroup;
|
||||
siteUrl: string;
|
||||
siteConfig: any;
|
||||
|
@ -48,6 +49,14 @@ export class CoreLoginEmailSignupPage {
|
|||
recaptcharesponse: ''
|
||||
};
|
||||
|
||||
// Data for age verification.
|
||||
ageVerificationForm: FormGroup;
|
||||
countryControl: FormControl;
|
||||
isMinor = false; // Whether the user is minor age.
|
||||
ageDigitalConsentVerification: boolean; // Whether the age verification is enabled.
|
||||
supportName: string;
|
||||
supportEmail: string;
|
||||
|
||||
// Validation errors.
|
||||
usernameErrors: any;
|
||||
passwordErrors: any;
|
||||
|
@ -63,6 +72,13 @@ export class CoreLoginEmailSignupPage {
|
|||
|
||||
this.siteUrl = navParams.get('siteUrl');
|
||||
|
||||
// Create the ageVerificationForm.
|
||||
this.ageVerificationForm = this.fb.group({
|
||||
age: ['', Validators.required]
|
||||
});
|
||||
this.countryControl = this.fb.control('', Validators.required);
|
||||
this.ageVerificationForm.addControl('country', this.countryControl);
|
||||
|
||||
// Create the signupForm with the basic controls. More controls will be added later.
|
||||
this.signupForm = this.fb.group({
|
||||
username: ['', Validators.required],
|
||||
|
@ -115,7 +131,20 @@ export class CoreLoginEmailSignupPage {
|
|||
this.siteConfig = config;
|
||||
|
||||
if (this.treatSiteConfig(config)) {
|
||||
return this.getSignupSettings();
|
||||
// Check content verification.
|
||||
if (typeof this.ageDigitalConsentVerification == 'undefined') {
|
||||
return this.wsProvider.callAjax('core_auth_is_age_digital_consent_verification_enabled', {},
|
||||
{siteUrl: this.siteUrl }).then((result) => {
|
||||
|
||||
this.ageDigitalConsentVerification = result.status;
|
||||
}).catch((e) => {
|
||||
// Capture exceptions, fail silently.
|
||||
}).then(() => {
|
||||
return this.getSignupSettings();
|
||||
});
|
||||
} else {
|
||||
return this.getSignupSettings();
|
||||
}
|
||||
}
|
||||
}).then(() => {
|
||||
this.completeFormGroup();
|
||||
|
@ -136,6 +165,10 @@ export class CoreLoginEmailSignupPage {
|
|||
this.captcha.recaptcharesponse = ''; // Reset captcha.
|
||||
}
|
||||
|
||||
if (!this.countryControl.value) {
|
||||
this.countryControl.setValue(settings.country || '');
|
||||
}
|
||||
|
||||
this.namefieldsErrors = {};
|
||||
if (settings.namefields) {
|
||||
settings.namefields.forEach((field) => {
|
||||
|
@ -160,6 +193,10 @@ export class CoreLoginEmailSignupPage {
|
|||
if (siteConfig && siteConfig.registerauth == 'email' && !this.loginHelper.isEmailSignupDisabled(siteConfig)) {
|
||||
this.siteName = siteConfig.sitename;
|
||||
this.authInstructions = siteConfig.authinstructions;
|
||||
this.ageDigitalConsentVerification = siteConfig.agedigitalconsentverification;
|
||||
this.supportName = siteConfig.supportname;
|
||||
this.supportEmail = siteConfig.supportemail;
|
||||
this.countryControl.setValue(siteConfig.country || '');
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
@ -229,7 +266,7 @@ export class CoreLoginEmailSignupPage {
|
|||
if (result.warnings && result.warnings.length) {
|
||||
let error = result.warnings[0].message;
|
||||
if (error == 'incorrect-captcha-sol') {
|
||||
error = this.translate.instant('mm.login.recaptchaincorrect');
|
||||
error = this.translate.instant('core.login.recaptchaincorrect');
|
||||
}
|
||||
|
||||
this.domUtils.showErrorModal(error);
|
||||
|
@ -252,4 +289,42 @@ export class CoreLoginEmailSignupPage {
|
|||
protected showAuthInstructions(): void {
|
||||
this.textUtils.expandText(this.translate.instant('core.login.instructions'), this.authInstructions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show contact information on site (we have to display again the age verification form).
|
||||
*/
|
||||
showContactOnSite(): void {
|
||||
this.utils.openInBrowser(this.siteUrl + '/login/verify_age_location.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify Age.
|
||||
*/
|
||||
verifyAge(): void {
|
||||
if (!this.ageVerificationForm.valid) {
|
||||
this.domUtils.showErrorModal('core.errorinvalidform', true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const modal = this.domUtils.showModalLoading('core.sending', true),
|
||||
params = this.ageVerificationForm.value;
|
||||
|
||||
params.age = parseInt(params.age, 10); // Use just the integer part.
|
||||
|
||||
this.wsProvider.callAjax('core_auth_is_minor', params, {siteUrl: this.siteUrl}).then((result) => {
|
||||
if (!result.status) {
|
||||
// Not a minor, go ahead!
|
||||
this.ageDigitalConsentVerification = false;
|
||||
} else {
|
||||
// Is a minor!!
|
||||
this.isMinor = true;
|
||||
}
|
||||
}).catch(() => {
|
||||
// Something wrong, redirect to the site.
|
||||
this.domUtils.showErrorModal('There was an error verifying your age, please try again using the browser.');
|
||||
}).finally(() => {
|
||||
modal.dismiss();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<!-- If no sitename show big siteurl. -->
|
||||
<p *ngIf="!siteName" class="item-heading core-siteurl">{{siteUrl}}</p>
|
||||
<!-- If sitename, show big sitename and small siteurl. -->
|
||||
<p *ngIf="siteName" class="item-heading core-sitename">{{siteName}}</p>
|
||||
<p *ngIf="siteName" class="item-heading core-sitename"><core-format-text [text]="siteName"></core-format-text></p>
|
||||
<p *ngIf="siteName" class="core-siteurl">{{siteUrl}}</p>
|
||||
|
||||
<p *ngIf="!isLoggedOut">
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"accounts": "Accounts",
|
||||
"add": "Add",
|
||||
"agelocationverification": "Age and location verification",
|
||||
"allparticipants": "All participants",
|
||||
"android": "Android",
|
||||
"answer": "Answer",
|
||||
|
@ -34,6 +35,7 @@
|
|||
"confirmdeletefile": "Are you sure you want to delete this file?",
|
||||
"confirmloss": "Are you sure? All changes will be lost.",
|
||||
"confirmopeninbrowser": "Do you want to open it in browser?",
|
||||
"considereddigitalminor": "You are considered to be a digital minor.",
|
||||
"content": "Content",
|
||||
"continue": "Continue",
|
||||
"contenteditingsynced": "The content you are editing has been synced.",
|
||||
|
@ -57,6 +59,8 @@
|
|||
"dflastweekdate": "ddd",
|
||||
"dfmediumdate": "LLL",
|
||||
"dftimedate": "h[:]mm A",
|
||||
"digitalminor": "Digital minor",
|
||||
"digitalminor_desc": "To create an account on this site please have your parent/guardian contact the following person.",
|
||||
"discard": "Discard",
|
||||
"dismiss": "Dismiss",
|
||||
"done": "Done",
|
||||
|
@ -79,6 +83,7 @@
|
|||
"errorrenamefile": "Error renaming the file. Please try again.",
|
||||
"errorsync": "An error occurred while synchronizing. Please try again.",
|
||||
"errorsyncblocked": "This {{$a}} cannot be synchronized right now because of an ongoing process. Please try again later. If the problem persists, try restarting the app.",
|
||||
"explanationdigitalminor": "This information is required to determine if your age is over the digital age of consent. This is the age when an individual can consent to terms and conditions and their data being legally stored and processed.",
|
||||
"filename": "Filename",
|
||||
"filenameexist": "File name already exists: {{$a}}",
|
||||
"folder": "Folder",
|
||||
|
@ -168,6 +173,7 @@
|
|||
"phone": "Phone",
|
||||
"pictureof": "Picture of {{$a}}",
|
||||
"previous": "Previous",
|
||||
"proceed": "Proceed",
|
||||
"pulltorefresh": "Pull to refresh",
|
||||
"quotausage": "You have currently used {{$a.used}} of your {{$a.total}} limit.",
|
||||
"redirectingtosite": "You will be redirected to site.",
|
||||
|
@ -223,8 +229,11 @@
|
|||
"view": "View",
|
||||
"viewprofile": "View profile",
|
||||
"warningofflinedatadeleted": "Offline data of {{component}} '{{name}}' has been deleted. {{error}}",
|
||||
"whatisyourage": "What is your age?",
|
||||
"wheredoyoulive": "In which country do you live?",
|
||||
"whoops": "Oops!",
|
||||
"whyisthishappening": "Why is this happening?",
|
||||
"whyisthisrequired": "Why is this required?",
|
||||
"windowsphone": "Windows Phone",
|
||||
"wsfunctionnotavailable": "The webservice function is not available.",
|
||||
"year" : "year",
|
||||
|
|
Loading…
Reference in New Issue