diff options
author | Chocobozzz <me@florianbigard.com> | 2023-02-14 11:47:01 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-02-14 11:51:44 +0100 |
commit | 98bd5e2256bfdeba6d5ab07f0421acfde1a0de26 (patch) | |
tree | a1193f1af10f0da7a532d4aa6d5045e51c3d16a9 /client/src/app/core/routing/login-guard.service.ts | |
parent | 4ea827076df39935375d66fffb5e1e27e667111e (diff) | |
download | PeerTube-98bd5e2256bfdeba6d5ab07f0421acfde1a0de26.tar.gz PeerTube-98bd5e2256bfdeba6d5ab07f0421acfde1a0de26.tar.zst PeerTube-98bd5e2256bfdeba6d5ab07f0421acfde1a0de26.zip |
Refactor login redirection/button links
Correctly handle external auth redirection in all cases
Diffstat (limited to 'client/src/app/core/routing/login-guard.service.ts')
-rw-r--r-- | client/src/app/core/routing/login-guard.service.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/client/src/app/core/routing/login-guard.service.ts b/client/src/app/core/routing/login-guard.service.ts index a949be14c..2f5a31e7f 100644 --- a/client/src/app/core/routing/login-guard.service.ts +++ b/client/src/app/core/routing/login-guard.service.ts | |||
@@ -1,19 +1,20 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router' | 2 | import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router' |
3 | import { AuthService } from '../auth/auth.service' | 3 | import { AuthService } from '../auth/auth.service' |
4 | import { RedirectService } from './redirect.service' | ||
4 | 5 | ||
5 | @Injectable() | 6 | @Injectable() |
6 | export class LoginGuard implements CanActivate, CanActivateChild { | 7 | export class LoginGuard implements CanActivate, CanActivateChild { |
7 | 8 | ||
8 | constructor ( | 9 | constructor ( |
9 | private router: Router, | 10 | private auth: AuthService, |
10 | private auth: AuthService | 11 | private redirectService: RedirectService |
11 | ) {} | 12 | ) {} |
12 | 13 | ||
13 | canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { | 14 | canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { |
14 | if (this.auth.isLoggedIn() === true) return true | 15 | if (this.auth.isLoggedIn() === true) return true |
15 | 16 | ||
16 | this.router.navigate([ '/login' ]) | 17 | this.redirectService.redirectToLogin() |
17 | return false | 18 | return false |
18 | } | 19 | } |
19 | 20 | ||