]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/routing/login-guard.service.ts
Refactor login redirection/button links
[github/Chocobozzz/PeerTube.git] / client / src / app / core / routing / login-guard.service.ts
index 7b1c37ee8929976022d60ff1592d4ef9fcf28e58..2f5a31e7f3011fe84e7b0f36856fbeeba1eba508 100644 (file)
@@ -1,20 +1,20 @@
 import { Injectable } from '@angular/core'
-import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, Router, RouterStateSnapshot } from '@angular/router'
-
+import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot } from '@angular/router'
 import { AuthService } from '../auth/auth.service'
+import { RedirectService } from './redirect.service'
 
 @Injectable()
 export class LoginGuard implements CanActivate, CanActivateChild {
 
   constructor (
-    private router: Router,
-    private auth: AuthService
+    private auth: AuthService,
+    private redirectService: RedirectService
   ) {}
 
   canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
     if (this.auth.isLoggedIn() === true) return true
 
-    this.router.navigate([ '/login' ])
+    this.redirectService.redirectToLogin()
     return false
   }