client/auth: forget user when they try to log in
This is to let user log in if their login cookie is broken (for example when it refers to a non existing user). Normally, the client should treat errors caused by cookie logins as temporary server failures, inform the user about it and leave the cookie, so that when the server is up again, all user needs to do is to reload the page rather than logging again.
This commit is contained in:
parent
0d2fc830a6
commit
da1386c7d2
2 changed files with 10 additions and 4 deletions
|
@ -24,6 +24,7 @@ class AuthController {
|
|||
}
|
||||
|
||||
loginRoute() {
|
||||
api.forget();
|
||||
topNavController.activate('login');
|
||||
this.loginView.render({
|
||||
login: (name, password, doRemember) => {
|
||||
|
|
|
@ -30,8 +30,13 @@ const api = require('./api.js');
|
|||
api.loginFromCookies().then(() => {
|
||||
page();
|
||||
}).catch(errorMessage => {
|
||||
page('/');
|
||||
events.notify(
|
||||
events.Error,
|
||||
'An error happened while trying to log you in: ' + errorMessage);
|
||||
if (window.location.href.indexOf('login') !== -1) {
|
||||
api.forget();
|
||||
page();
|
||||
} else {
|
||||
page('/');
|
||||
events.notify(
|
||||
events.Error,
|
||||
'An error happened while trying to log you in: ' + errorMessage);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue