I have set the token for my application to expire after 30 minutes, and I have configured the 401/403 error handling as follows:
// Handling 401 or 403 error
async unauthorisedError() {
const alert = await this.alertController.create({
header: 'Session has expired',
message: 'Click OK to login again',
buttons: [
{
text: 'OK',
role: 'cancel',
cssClass: 'secondary',
handler: close => {
console.log('close unauthorized');
this.storage.clear();
this.authenticationService.login();
this.open = false;
// do nothing else
}
}
]
});
alert.present();
}
After the user logs back in, they should be redirected straight to the homepage. However, there seems to be a delay of 1-3 seconds where the app reverts back to the previous screen before redirecting.
Is there a way to prevent this brief reverting behavior, or is it just the code catching up with itself?
Any suggestions would be appreciated. Thanks!