|
|
@ -70,10 +70,16 @@ let authorizeToken = async function (ctx, token) { |
|
|
|
const tokenFormatRegexp = /^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$/g; |
|
|
|
if (token && tokenFormatRegexp.test(token)) { |
|
|
|
try { |
|
|
|
const expired = await ctx.redis.hget(token, 'expired'); |
|
|
|
// const expired = await ctx.redis.hget(token, 'expired');
|
|
|
|
|
|
|
|
if (expired && moment().valueOf() <= moment(expired).valueOf()) { |
|
|
|
const userInfo = JSON.parse(await ctx.redis.hget(token, 'userInfo')); |
|
|
|
let userInfo = await ctx.redis.get(token); |
|
|
|
if ( |
|
|
|
userInfo |
|
|
|
// expired && moment().valueOf() <= moment(expired).valueOf()
|
|
|
|
) { |
|
|
|
// const userInfo = JSON.parse(await ctx.redis.hget(token, 'userInfo'));
|
|
|
|
|
|
|
|
userInfo = JSON.parse(userInfo); |
|
|
|
rslt = { |
|
|
|
'authorized': userInfo.authorized, |
|
|
|
'resources': (userInfo || {}).resources || [], |
|
|
@ -83,7 +89,7 @@ let authorizeToken = async function (ctx, token) { |
|
|
|
ctx.fs.api.token = token; |
|
|
|
} |
|
|
|
} catch (err) { |
|
|
|
console.log(11111111111,err); |
|
|
|
console.error(err); |
|
|
|
const { error } = err.response || {}; |
|
|
|
ctx.fs.logger.log('[anxinyun]', '[AUTH] failed', (error || {}).message || `cannot GET /users/${token}`); |
|
|
|
} |
|
|
|