|
@ -70,14 +70,9 @@ 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; |
|
|
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)) { |
|
|
if (token && tokenFormatRegexp.test(token)) { |
|
|
try { |
|
|
try { |
|
|
const tokenRes = await ctx.fs.dc.models.UserToken.findOne({ |
|
|
const expired = await ctx.redis.hget(token, 'expired'); |
|
|
where: { |
|
|
if (expired && moment().valueOf() <= moment(expired).valueOf()) { |
|
|
token: token, |
|
|
const userInfo = JSON.parse(await ctx.redis.hget(token, 'userInfo')); |
|
|
expired: { $gte: moment().format('YYYY-MM-DD HH:mm:ss') } |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
const { userInfo, expired } = tokenRes; |
|
|
|
|
|
if (!expired || moment().valueOf() <= moment(expired).valueOf()) { |
|
|
|
|
|
rslt = { |
|
|
rslt = { |
|
|
'authorized': userInfo.authorized, |
|
|
'authorized': userInfo.authorized, |
|
|
'resources': (userInfo || {}).resources || [], |
|
|
'resources': (userInfo || {}).resources || [], |
|
|