From ec769c89fdcbcaf2d15de8d211d3ede3b6f69c1a Mon Sep 17 00:00:00 2001 From: BO41 Date: Sun, 23 Sep 2018 16:37:48 +0200 Subject: add redirect after login (#1110) --- client/src/app/core/auth/auth.service.ts | 3 +++ client/src/app/core/routing/login-guard.service.ts | 2 ++ 2 files changed, 5 insertions(+) (limited to 'client/src/app/core') diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 88ea89639..8ff5713a1 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -38,6 +38,7 @@ export class AuthService { loginChangedSource: Observable userInformationLoaded = new ReplaySubject(1) hotkeys: Hotkey[] + redirectUrl: string private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID) private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET) @@ -177,6 +178,8 @@ export class AuthService { this.setStatus(AuthStatus.LoggedOut) this.hotkeysService.remove(this.hotkeys) + + this.redirectUrl = null } refreshAccessToken () { diff --git a/client/src/app/core/routing/login-guard.service.ts b/client/src/app/core/routing/login-guard.service.ts index 18bc41ca6..40ff8f505 100644 --- a/client/src/app/core/routing/login-guard.service.ts +++ b/client/src/app/core/routing/login-guard.service.ts @@ -20,6 +20,8 @@ export class LoginGuard implements CanActivate, CanActivateChild { canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { if (this.auth.isLoggedIn() === true) return true + this.auth.redirectUrl = state.url + this.router.navigate([ '/login' ]) return false } -- cgit v1.2.3