Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Injectable()
- export class AuthGuard implements CanActivate {
- public router: Router;
- public serverThisLogin: ServerDataComponent;
- constructor(router: Router) {
- this.router = router;
- }
- public canActivate(): boolean {
- if (this.serverThisLogin.isLogin) {
- return true;
- }
- this.router.navigate(["/login"]);
- return false;
- }
- }
- public isLogin (username: string, password: string): Observable<boolean> {
- return this.http.post( authURL + loginURL,
- JSON.stringify({ password, username }))
- .map((response: Response) => {
- if (response.status === 200) {
- return true;
- } else {
- return false;
- }
- });
- }
- { canActivate: [AuthGuard], component: LaskComponent, path: "table_per" }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement