MOBILE-3833 core: Don't display token expired error modal
The same message is displayed in reconnect page.main
parent
b3cadf8cd7
commit
8dbefef88b
|
@ -1970,7 +1970,6 @@
|
|||
"core.login.recaptchaexpired": "local_moodlemobileapp",
|
||||
"core.login.recaptchaincorrect": "local_moodlemobileapp",
|
||||
"core.login.reconnect": "local_moodlemobileapp",
|
||||
"core.login.reconnectdescription": "local_moodlemobileapp",
|
||||
"core.login.reconnectssodescription": "local_moodlemobileapp",
|
||||
"core.login.removeaccount": "local_moodlemobileapp",
|
||||
"core.login.resendemail": "moodle",
|
||||
|
|
|
@ -45,6 +45,7 @@ import { CoreSites } from '@services/sites';
|
|||
import { asyncInstance, AsyncInstance } from '../utils/async-instance';
|
||||
import { CoreDatabaseTable } from './database/database-table';
|
||||
import { CoreDatabaseCachingStrategy } from './database/database-table-proxy';
|
||||
import { CoreSilentError } from './errors/silenterror';
|
||||
|
||||
/**
|
||||
* QR Code type enumeration.
|
||||
|
@ -520,7 +521,8 @@ export class CoreSite {
|
|||
// Site is logged out, it cannot call WebServices.
|
||||
CoreEvents.trigger(CoreEvents.SESSION_EXPIRED, {}, this.id);
|
||||
|
||||
throw new CoreError(Translate.instant('core.lostconnection'));
|
||||
// Use a silent error, the SESSION_EXPIRED event will display a message if needed.
|
||||
throw new CoreSilentError(Translate.instant('core.lostconnection'));
|
||||
}
|
||||
|
||||
const initialToken = this.token || '';
|
||||
|
@ -610,6 +612,8 @@ export class CoreSite {
|
|||
|
||||
return response;
|
||||
} catch (error) {
|
||||
let useSilentError = false;
|
||||
|
||||
if (CoreUtils.isExpiredTokenError(error)) {
|
||||
if (initialToken !== this.token && !retrying) {
|
||||
// Token has changed, retry with the new token.
|
||||
|
@ -627,6 +631,7 @@ export class CoreSite {
|
|||
CoreEvents.trigger(CoreEvents.SESSION_EXPIRED, {}, this.id);
|
||||
// Change error message. Try to get data from cache, the event will handle the error.
|
||||
error.message = Translate.instant('core.lostconnection');
|
||||
useSilentError = true; // Use a silent error, the SESSION_EXPIRED event will display a message if needed.
|
||||
} else if (error.errorcode === 'userdeleted' || error.errorcode === 'wsaccessuserdeleted') {
|
||||
// User deleted, trigger event.
|
||||
CoreEvents.trigger(CoreEvents.USER_DELETED, { params: data }, this.id);
|
||||
|
@ -707,7 +712,11 @@ export class CoreSite {
|
|||
|
||||
try {
|
||||
return await this.getFromCache<T>(method, data, preSets, true);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
if (useSilentError) {
|
||||
throw new CoreSilentError(error.message);
|
||||
}
|
||||
|
||||
throw new CoreWSError(error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,6 @@
|
|||
"recaptchaexpired": "Verification expired. Answer the security question again.",
|
||||
"recaptchaincorrect": "The security question answer is incorrect.",
|
||||
"reconnect": "Reconnect",
|
||||
"reconnectdescription": "Your authentication token is invalid or has expired. You have to reconnect to the site.",
|
||||
"reconnectssodescription": "Your authentication token is invalid or has expired. You have to reconnect to the site. You need to log in to the site in a browser window.",
|
||||
"removeaccount": "Remove account",
|
||||
"resendemail": "Resend email",
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<ion-item>
|
||||
<ion-icon name="fas-exclamation-circle" slot="start" aria-hidden="true"></ion-icon>
|
||||
<ion-label>
|
||||
<p>{{ 'core.login.reconnectdescription' | translate }}</p>
|
||||
<p>{{ 'core.lostconnection' | translate }}</p>
|
||||
</ion-label>
|
||||
</ion-item>
|
||||
</ion-card>
|
||||
|
|
Loading…
Reference in New Issue