AuthGuard.prototype.canActivate = function () {
     if (angular2_jwt_1.tokenNotExpired()) {
         return true;
     }
     this.router.navigate(['/login']);
     return false;
 };
 Authservice.prototype.authenticated = function () {
     if (angular2_jwt_1.tokenNotExpired("auth_key")) {
         return true;
     }
     else {
         this.emitNotLoggedIn();
         return false;
     }
 };
Example #3
0
 function LoginService(http, authHttp) {
     this.http = http;
     this.authHttp = authHttp;
     this.loginUrl = 'http://localhost:8080/Pizza/login';
     this.jwtHelper = new angular2_jwt_1.JwtHelper();
     this.isLoggedin = false;
     if (angular2_jwt_1.tokenNotExpired('jwt')) {
         console.info("logged in");
         this.isLoggedin = true;
         this.user = this.getUserFromJwt();
         console.info("user=" + this.user);
     }
 }
 Auth.prototype.authenticated = function () {
     // Check if there's an unexpired JWT
     // It searches for an item in localStorage with key == 'id_token'
     return angular2_jwt_1.tokenNotExpired();
 };