当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript JwtHelper.decodeToken方法代码示例

本文整理汇总了TypeScript中angular2-jwt.JwtHelper.decodeToken方法的典型用法代码示例。如果您正苦于以下问题:TypeScript JwtHelper.decodeToken方法的具体用法?TypeScript JwtHelper.decodeToken怎么用?TypeScript JwtHelper.decodeToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在angular2-jwt.JwtHelper的用法示例。


在下文中一共展示了JwtHelper.decodeToken方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Date

            .mergeMap((token) => {
                const decodedToken = this.jwtHelper.decodeToken(token);

                return Observable.interval(
                    new Date(0).setUTCSeconds(decodedToken.exp) - new Date(0).setUTCSeconds(decodedToken.iat)
                );
            })
开发者ID:Invis1ble,项目名称:assistant-client,代码行数:7,代码来源:auth.service.ts

示例2: getJwt

  public getJwt(): any {
    var jwtHelper = new JwtHelper();
    var encodedToken = window.localStorage.getItem('jwt');
    var jwt = jwtHelper.decodeToken(encodedToken);

    return jwt;
  }
开发者ID:smithandrewl,项目名称:manytasks,代码行数:7,代码来源:authentication.service.ts

示例3: getUserName

 getUserName(): string {
   if (window.localStorage.getItem('token')) {
     let token = window.localStorage.getItem('token');
     let decoded = this.jwtHelper.decodeToken(token);
     return decoded.login
   } else {
     return "not logged in"
   }
 }
开发者ID:TypeScriptUserGroupDE,项目名称:homepage,代码行数:9,代码来源:auth.service.ts

示例4:

 this.authProvider.authUser.subscribe(jwt => {
   if (jwt) {
     const decoded = this.jwtHelper.decodeToken(jwt);
     this.user = decoded.sub
   }
   else {
     this.user = null;
   }
 });
开发者ID:francasense,项目名称:blog,代码行数:9,代码来源:home.ts

示例5: saveToken

 private saveToken(data: any): boolean {
   if (data.status) {
     let decodedToken = this.jwtHelper.decodeToken(data.jwt);
     localStorage.setItem('profile', JSON.stringify(decodedToken));
     localStorage.setItem('id_token', data.jwt);
     return true;
   } else {
     return false;
   }
 }
开发者ID:GECOR,项目名称:gecor-generic-2016,代码行数:10,代码来源:auth.ts

示例6: canActivate

  canActivate() {
    var token = localStorage.getItem("jwt");
 
    if (token && !this.jwtHelper.isTokenExpired(token)){
        console.log(this.jwtHelper.decodeToken(token));
        return true;
    }
    this.router.navigate(["login"]);
    return false;
  }
开发者ID:joeymalouf,项目名称:GraduationGuideline,代码行数:10,代码来源:auth-gaurd.service.ts

示例7: Number

 timer.subscribe(t => {
   var token = jwtHelper.decodeToken(localStorage.getItem('id_token'));
   if (token) {
     this.tokenExpires = ((token.exp * 1000) - Number(new Date()));
     this.tokenExpired = this.tokenExpires <= 0;
     if (this.tokenExpires > -5000 && this.tokenExpires < 2000) {
       this.refreshToken();
     }
   }
 });
开发者ID:adrianobalani,项目名称:gestaolivre-frontend,代码行数:10,代码来源:gestaolivre.ts

示例8: tokenDecode

    tokenDecode() {

        let token = localStorage.getItem('id_token');

        if (!token) {

            return "unathorized";
        } else {

            return this.jwtHelper.decodeToken(token);
        }
    }
开发者ID:ecos-codeaholics,项目名称:factory-of-procedures-front,代码行数:12,代码来源:jwt-helper.service.ts

示例9: currentUser

 get currentUser() {
     if (this._currentUser) {
         return Promise.resolve(this._currentUser);
     } else {
         let deserializedToken = jwtHelper.decodeToken(this._store.getString('authtoken'));
         let userId = deserializedToken.sub;
         return this.get(Number(userId)).then(user => {
             this._currentUser = user;
             return user;
         });
     }
 }
开发者ID:csgpro,项目名称:csgpro.com,代码行数:12,代码来源:user.service.ts

示例10: User

 response => {
     var idToken = response.json().token;
     console.log(idToken);
     localStorage.setItem('id_token', idToken);
     let token = this.jwtHelper.decodeToken(idToken);
     console.log(token);						
     //TODO get the user from the response object;
     this.currentUser = new User();
     this.currentUser._id = token._id;
     this.currentUser.name = token.name;
     this.currentUser.role = token.role;
     observer.next('SUCCESS');
 },
开发者ID:z424brave,项目名称:DKClient,代码行数:13,代码来源:auth-service.ts


注:本文中的angular2-jwt.JwtHelper.decodeToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。