Merge pull request #4502 from FinnStutzenstein/fixRedirectionOnDelayedWhoAmI

Fixed redirection on login subpages (fixed #4474)
This commit is contained in:
Sean 2019-03-13 15:31:21 +01:00 committed by GitHub
commit 7734a502d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,18 +66,7 @@ export class OpenSlidesService {
const response = await this.operator.whoAmIFromStorage();
if (!response.user && !response.guest_enabled) {
this.redirectUrl = location.pathname;
// let the use navigate and reload on every login-page
if (this.redirectUrl.includes('/login/')) {
// Allow free navigation in the children of the login page
// required for resetting password and direct navigation to legal notice
// and privacy policy.
this.router.navigate([this.redirectUrl]);
} else {
// Goto login, if the user isn't login and guests are not allowed
this.router.navigate(['/login']);
}
this.redirectToLoginIfNotSubpage();
this.checkOperator(false);
} else {
await this.afterLoginBootup(response.user_id);
@ -88,6 +77,17 @@ export class OpenSlidesService {
}
}
/**
* Redirects the user to /login, if he isn't on a subpage.
*/
private redirectToLoginIfNotSubpage(): void {
if (!this.redirectUrl.includes('/login/')) {
// Goto login, if the user isn't on a subpage like
// legal notice or reset passwort view.
this.router.navigate(['/login']);
}
}
/**
* the login bootup-sequence: Check (and maybe clear) the cache und setup the DataStore
* and websocket. This "login" also may be the "login" of an anonymous when he is using
@ -152,7 +152,7 @@ export class OpenSlidesService {
// User logged off.
if (!response.user && !response.guest_enabled) {
await this.shutdown();
this.router.navigate(['/login']);
this.redirectToLoginIfNotSubpage();
} else {
if (
(this.operator.user && this.operator.user.id !== response.user_id) ||