我使用 jsonwebtoken 来解码我的令牌以查看它是否已过期。但是,console.log 返回 null。
var token = response.headers.authorization;
token = token.replace('Bearer','');
var jwt = require('jsonwebtoken');
var decoded = jwt.decode(token);
console.log(decoded);
Run Code Online (Sandbox Code Playgroud)
我不明白,因为我的令牌不为空
我正在用 Jhipster 创建一个应用程序。为此,我想使用 Keycloak 身份验证服务器。但是一旦我登录,我就会收到以下消息:状态:内部服务器错误(内部服务器错误)消息:尝试解码 Jwt 时发生错误:Jwt 在 2019-06-04T00:20:05Z 过期
我的 .yo-rc.json :
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.front.project",
"nativeLanguage": "fr"
},
"jhipsterVersion": "6.0.1",
"applicationType": "gateway",
"baseName": "frontProduit",
"packageName": "com.mycompany.front.project",
"packageFolder": "com/mycompany/front/project",
"serverPort": "8080",
"authenticationType": "oauth2",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "consul",
"buildTool": "maven",
"enableSwaggerCodegen": false,
"clientFramework": "angularX",
"clientTheme": "none",
"clientThemeVariant": "",
"useSass": true,
"clientPackageManager": "npm",
"testFrameworks": [],
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"enableTranslation": …Run Code Online (Sandbox Code Playgroud) 我在我的函数中使用了 _.isEqual 方法:
const Sidebar = ({ ...props }) => {
function myFunction(codeMenu) {
let menu = null;
const listMenu = props.listMenu;
for(var i = 0; i < listMenu.length; i++){
if(_.isEqual(listMenu[i].code, codeMenu)){
menu = listMenu[i];
}
break;
}
}
}
...
Run Code Online (Sandbox Code Playgroud)
但我有这个错误:
'_' is not defined no-undef
loadsh 在我的 index.html 中导入:https ://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js