MOBILE-4059 login: Treat invalidlogin error

main
Noel De Martin 2022-11-15 12:14:46 +01:00
parent 001a19f066
commit 8b8c4d533a
1 changed files with 27 additions and 10 deletions

View File

@ -39,6 +39,7 @@ import { CorePushNotifications } from '@features/pushnotifications/services/push
import { CoreText } from '@singletons/text';
import { CorePromisedValue } from '@classes/promised-value';
import { SafeHtml } from '@angular/platform-browser';
import { CoreLoginError } from '@classes/errors/loginerror';
const PASSWORD_RESETS_CONFIG_KEY = 'password-resets';
@ -1026,6 +1027,13 @@ export class CoreLoginHelperProvider {
(!CoreConstants.CONFIG.skipssoconfirmation || String(CoreConstants.CONFIG.skipssoconfirmation) === 'false');
}
/**
* Show a modal warning that the credentials introduced were not correct.
*/
protected showInvalidLoginModal(error: CoreLoginError): void {
CoreDomUtils.showErrorModal(error.errorDetails ?? error.message);
}
/**
* Show a modal warning the user that he should use the Workplace app.
*
@ -1167,16 +1175,25 @@ export class CoreLoginHelperProvider {
* @param password User password.
*/
treatUserTokenError(siteUrl: string, error: CoreWSError, username?: string, password?: string): void {
if (error.errorcode == 'forcepasswordchangenotice') {
switch (error.errorcode) {
case 'forcepasswordchangenotice':
this.openChangePassword(siteUrl, CoreTextUtils.getErrorMessageFromError(error)!);
} else if (error.errorcode == 'usernotconfirmed') {
break;
case 'usernotconfirmed':
this.showNotConfirmedModal(siteUrl, undefined, username, password);
} else if (error.errorcode == 'connecttomoodleapp') {
break;
case 'connecttomoodleapp':
this.showMoodleAppNoticeModal(CoreTextUtils.getErrorMessageFromError(error)!);
} else if (error.errorcode == 'connecttoworkplaceapp') {
break;
case 'connecttoworkplaceapp':
this.showWorkplaceNoticeModal(CoreTextUtils.getErrorMessageFromError(error)!);
} else {
break;
case 'invalidlogin':
this.showInvalidLoginModal(error);
break;
default:
CoreDomUtils.showErrorModal(error);
break;
}
}