-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quando o usuário estiver logado não consegue acessar login e registro
Signed-off-by: DaviMarinho <[email protected]>
- Loading branch information
1 parent
0706173
commit f18415b
Showing
3 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { NoTokenGuard } from './no-token.guard'; | ||
|
||
describe('NoTokenGuard', () => { | ||
let guard: NoTokenGuard; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
guard = TestBed.inject(NoTokenGuard); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(guard).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { CanActivate, Router } from '@angular/router'; | ||
import { AuthService } from './auth.service'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class NoTokenGuard implements CanActivate { | ||
constructor(private authService: AuthService, private router: Router) {} | ||
|
||
canActivate(): boolean { | ||
if (!this.authService.isAuthenticated()) { | ||
return true; | ||
} else { | ||
this.router.navigate(['/videos']); | ||
return false; | ||
} | ||
} | ||
} |