commit
0c436820bb
|
@ -33,6 +33,7 @@
|
||||||
"invalidvaluemax": "The maximum value is {{$a}}",
|
"invalidvaluemax": "The maximum value is {{$a}}",
|
||||||
"invalidvaluemin": "The minimum value is {{$a}}",
|
"invalidvaluemin": "The minimum value is {{$a}}",
|
||||||
"legacymoodleversion": "You are trying to connect to an unsupported Moodle version. Please, download the Moodle Classic app to access this Moodle site.",
|
"legacymoodleversion": "You are trying to connect to an unsupported Moodle version. Please, download the Moodle Classic app to access this Moodle site.",
|
||||||
|
"legacymoodleversiondesktop": "You are trying to connect to <b>{{$a}}</b>.<br><br>This site is running an outdated unsupported version of Moodle which will not work with this Moodle Desktop App.<br><br>If this is your site please contact your local moodle partner to get assistance to update it.<br><br>See <a href=\"https://moodle.com/contact\">our contact page</a> to submit a request for assistance.",
|
||||||
"localmobileunexpectedresponse": "Moodle Mobile Additional Features check returned an unexpected response, you will be authenticated using the standard Mobile service.",
|
"localmobileunexpectedresponse": "Moodle Mobile Additional Features check returned an unexpected response, you will be authenticated using the standard Mobile service.",
|
||||||
"login": "Log in",
|
"login": "Log in",
|
||||||
"loginbutton": "Log in",
|
"loginbutton": "Log in",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Location } from '@angular/common';
|
import { Location } from '@angular/common';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform, AlertController } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
import { CoreConfigProvider } from '@providers/config';
|
import { CoreConfigProvider } from '@providers/config';
|
||||||
|
@ -83,7 +83,7 @@ export class CoreLoginHelperProvider {
|
||||||
private eventsProvider: CoreEventsProvider, private appProvider: CoreAppProvider, private utils: CoreUtilsProvider,
|
private eventsProvider: CoreEventsProvider, private appProvider: CoreAppProvider, private utils: CoreUtilsProvider,
|
||||||
private urlUtils: CoreUrlUtilsProvider, private configProvider: CoreConfigProvider, private platform: Platform,
|
private urlUtils: CoreUrlUtilsProvider, private configProvider: CoreConfigProvider, private platform: Platform,
|
||||||
private initDelegate: CoreInitDelegate, private sitePluginsProvider: CoreSitePluginsProvider,
|
private initDelegate: CoreInitDelegate, private sitePluginsProvider: CoreSitePluginsProvider,
|
||||||
private location: Location) {
|
private location: Location, private alertCtrl: AlertController) {
|
||||||
this.logger = logger.getInstance('CoreLoginHelper');
|
this.logger = logger.getInstance('CoreLoginHelper');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -924,6 +924,47 @@ export class CoreLoginHelperProvider {
|
||||||
(!CoreConfigConstants.skipssoconfirmation || String(CoreConfigConstants.skipssoconfirmation) === 'false');
|
(!CoreConfigConstants.skipssoconfirmation || String(CoreConfigConstants.skipssoconfirmation) === 'false');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a modal warning the user that he should use the Classic app.
|
||||||
|
*
|
||||||
|
* @param {string} message The warning message.
|
||||||
|
*/
|
||||||
|
protected showLegacyNoticeModal(message: string): void {
|
||||||
|
const isAndroid = this.platform.is('android'),
|
||||||
|
isIOS = this.platform.is('ios'),
|
||||||
|
buttons: any[] = [
|
||||||
|
{
|
||||||
|
text: this.translate.instant('core.ok'),
|
||||||
|
role: 'cancel'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isAndroid || isIOS) {
|
||||||
|
buttons.push({
|
||||||
|
text: this.translate.instant('core.download'),
|
||||||
|
handler: (): void => {
|
||||||
|
const link = isAndroid ? 'market://details?id=com.moodle.classic' :
|
||||||
|
'itms-apps://itunes.apple.com/app/id1403448117';
|
||||||
|
|
||||||
|
this.utils.openInBrowser(link);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const alert = this.alertCtrl.create({
|
||||||
|
message: message,
|
||||||
|
buttons: buttons
|
||||||
|
});
|
||||||
|
|
||||||
|
alert.present().then(() => {
|
||||||
|
if (!isAndroid && !isIOS) {
|
||||||
|
// Treat all anchors so they don't override the app.
|
||||||
|
const alertMessageEl: HTMLElement = alert.pageRef().nativeElement.querySelector('.alert-message');
|
||||||
|
this.domUtils.treatAnchors(alertMessageEl);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called when site policy is not agreed. Reserved for core use.
|
* Function called when site policy is not agreed. Reserved for core use.
|
||||||
*
|
*
|
||||||
|
@ -961,6 +1002,8 @@ export class CoreLoginHelperProvider {
|
||||||
treatUserTokenError(siteUrl: string, error: any): void {
|
treatUserTokenError(siteUrl: string, error: any): void {
|
||||||
if (error.errorcode == 'forcepasswordchangenotice') {
|
if (error.errorcode == 'forcepasswordchangenotice') {
|
||||||
this.openChangePassword(siteUrl, error.error || error.message || error.body || error.content);
|
this.openChangePassword(siteUrl, error.error || error.message || error.body || error.content);
|
||||||
|
} else if (error.errorcode == 'legacymoodleversion') {
|
||||||
|
this.showLegacyNoticeModal(error.error);
|
||||||
} else {
|
} else {
|
||||||
this.domUtils.showErrorModal(error);
|
this.domUtils.showErrorModal(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,9 +494,23 @@ export class CoreSitesProvider {
|
||||||
return siteId;
|
return siteId;
|
||||||
});
|
});
|
||||||
} else if (result == this.LEGACY_APP_VERSION) {
|
} else if (result == this.LEGACY_APP_VERSION) {
|
||||||
return Promise.reject(this.translate.instant('core.login.legacymoodleversion'));
|
let errorKey = 'core.login.legacymoodleversion',
|
||||||
|
params;
|
||||||
|
|
||||||
|
if (this.appProvider.isDesktop()) {
|
||||||
|
errorKey += 'desktop';
|
||||||
|
params = {$a: siteUrl};
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.reject({
|
||||||
|
error: this.translate.instant(errorKey, params),
|
||||||
|
errorcode: 'legacymoodleversion'
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject(this.translate.instant('core.login.invalidmoodleversion'));
|
return Promise.reject({
|
||||||
|
error: this.translate.instant('core.login.invalidmoodleversion'),
|
||||||
|
errorcode: 'invalidmoodleversion'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1205,7 +1205,7 @@ export class CoreDomUtilsProvider {
|
||||||
*
|
*
|
||||||
* @param {HTMLElement} container The HTMLElement that can contain anchors.
|
* @param {HTMLElement} container The HTMLElement that can contain anchors.
|
||||||
*/
|
*/
|
||||||
protected treatAnchors(container: HTMLElement): void {
|
treatAnchors(container: HTMLElement): void {
|
||||||
const anchors = Array.from(container.querySelectorAll('a'));
|
const anchors = Array.from(container.querySelectorAll('a'));
|
||||||
|
|
||||||
anchors.forEach((anchor) => {
|
anchors.forEach((anchor) => {
|
||||||
|
|
Loading…
Reference in New Issue