本文整理汇总了TypeScript中jwt-decode类的典型用法代码示例。如果您正苦于以下问题:TypeScript jwt-decode类的具体用法?TypeScript jwt-decode怎么用?TypeScript jwt-decode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了jwt-decode类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: jwtDecode
return state.map((u: AccountDTO) => {
if (u.login == action.login) {
console.log("update token " + u.primary + " " + baseWebCall.webToken + " " + action.jwtToken);
if (u.primary) {
baseWebCall.webToken = action.jwtToken;
}
var decodedToken: any = jwtDecode(action.jwtToken);
var iat: number = decodedToken.iat;
var exp: number = decodedToken.exp;
console.log("IAT " + new Date(iat * 1000).simpleFormatWithMinutes());
console.log("EXP " + new Date(exp * 1000).simpleFormatWithMinutes());
// co jak issued at bedzie
return Object.assign({}, u, {
id: jwtDecode(action.jwtToken).info.userId,
login: action.login,
jwtToken: action.jwtToken,
lastUpdated: Date.now(),
infoDescription: null,
inProgress: false,
tokenExpirationDate: new Date(exp * 1000)
});
} else
return u;
});
开发者ID:vinga,项目名称:challenger,代码行数:28,代码来源:accountReducers.ts
示例2: getAuthentication
function getAuthentication(token): Authentication {
if (token == null) {
return { token: null, claims: null, error: null };
} else {
const claims = jwt_decode(token);
if (claims['exp'] < new Date().getTime()/1000) {
return { token: null, claims: null, error: null };
} else {
return {token: token, claims: jwt_decode(token), error: null};
}
}
}
开发者ID:hemadri1982,项目名称:microservice-demo,代码行数:12,代码来源:auth.reducer.ts
示例3: ngOnInit
ngOnInit() {
this.projectList();
if (AppSettings.AUTH_TOKEN) {
let decodedJWT = JWT(AppSettings.AUTH_TOKEN);
this.canDelete = decodedJWT.privilege.includes("delete");
}
}
开发者ID:rlilojr,项目名称:skf-flask,代码行数:7,代码来源:project-list.component.ts
示例4: getClaims
getClaims(): any {
const token = this.tokenService.getToken();
if (!token) {
return {};
}
this.claims = this.claims || jwt_decode(token);
return this.claims;
}
开发者ID:brianpursley,项目名称:timesheet-demo,代码行数:8,代码来源:claims.service.ts
示例5: jwtDecode
'LOGIN_USER_SUCCESS': (state, payload) => {
return Object.assign({}, state, {
'isAuthenticating': false,
'isAuthenticated': true,
'token': payload.token,
'userName': jwtDecode(payload.token).userName,
'statusText': 'You have been successfully logged in.'
});
},
开发者ID:elleryapp,项目名称:ellery-frontend,代码行数:10,代码来源:auth.ts
示例6: getTokenExpirationDate
private getTokenExpirationDate(token:string): Date {
var decoded=null;
try{
decoded = jwt_decode(token);
}catch(err){
return null;
}
if (decoded.exp === undefined) return null;
const date = new Date(0);
date.setUTCSeconds(decoded.exp);
return date;
}
开发者ID:Borntorun2018,项目名称:FutureBank,代码行数:12,代码来源:token.storage.ts
示例7: jwtDecode
.then(response => {
try {
let decoded = jwtDecode(response.token);
dispatch(loginUserSuccess(response.token));
} catch (e) {
dispatch(loginUserFailure({
response: {
status: 403,
statusText: 'Invalid token'
}
}));
}
})
开发者ID:myfiurevamp,项目名称:frontend,代码行数:13,代码来源:actions.ts
示例8: canActivate
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) : boolean {
var token = localStorage.getItem("token")
if (token) {
var res = jwt(token)
if (
(!res["exp"] || res["exp"] >= new Date().getTime() / 1000) &&
(!res["nbf"] || res["nbf"] < new Date().getTime() / 1000)
) {
return true;
}
}
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }});
return false;
}
开发者ID:urandom,项目名称:readeef,代码行数:15,代码来源:auth.ts
示例9: getSession
function getSession(req: Request): {} | null {
const token = getAuthorizationToken(req);
// this just checks that a jwt is present and can be decoded. Validating
// the token against a pk would be good. Would also be good to validate the
// expiration.
if (token) {
try {
return jwt_decode(token);
} catch (err) {
console.warn("Error decoding token", err);
}
}
return null;
}
开发者ID:dianpeng,项目名称:fly,代码行数:17,代码来源:index.ts
示例10: canActivate
canActivate () {
let payload: any
const token = localStorage.getItem('token')
if (token) {
payload = jwt_decode(token)
}
if (payload && payload.data && payload.data.isAdmin) {
return true
} else {
this.router.navigate(['403'], {
skipLocationChange: true,
queryParams: {
error: 'UNAUTHORIZED_PAGE_ACCESS_ERROR'
}
})
return false
}
}
开发者ID:bkimminich,项目名称:juice-shop,代码行数:18,代码来源:app.routing.ts
注:本文中的jwt-decode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论