|
|
@ -71,8 +71,6 @@ 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 { |
|
|
|
console.log(`DurationCalc: auth 1 用时 ${moment().diff(startTime, 'milliseconds')}`); |
|
|
|
|
|
|
|
const expired = await ctx.redis.hget(token, 'expired'); |
|
|
|
|
|
|
|
// const authorizeRes = await ctx.app.fs.emisRequest.get('authorize', {
|
|
|
@ -80,7 +78,6 @@ let authorizeToken = async function (ctx, token) { |
|
|
|
// })
|
|
|
|
// const { userInfo, expired } = authorizeRes;
|
|
|
|
|
|
|
|
console.log(`DurationCalc: auth 2 用时 ${moment().diff(startTime, 'milliseconds')}`); |
|
|
|
|
|
|
|
// TODO 从项企 clickhouse 数据库中查 token 并更新
|
|
|
|
if (expired && moment().valueOf() <= moment(expired).valueOf()) { |
|
|
@ -93,7 +90,6 @@ let authorizeToken = async function (ctx, token) { |
|
|
|
// }
|
|
|
|
// }) || {}
|
|
|
|
|
|
|
|
console.log(`DurationCalc: auth 3 用时 ${moment().diff(startTime, 'milliseconds')}`); |
|
|
|
rslt = { |
|
|
|
'authorized': userInfo.authorized, |
|
|
|
'resources': (userInfo || {}).resources || [], |
|
|
@ -104,7 +100,6 @@ let authorizeToken = async function (ctx, token) { |
|
|
|
ctx.fs.api.pepUserInfo = userInfo; |
|
|
|
ctx.fs.api.token = token; |
|
|
|
} |
|
|
|
console.log(`DurationCalc: auth 4 用时 ${moment().diff(startTime, 'milliseconds')}`); |
|
|
|
} catch (err) { |
|
|
|
const { error } = err.response || {}; |
|
|
|
ctx.fs.logger.log('[anxinyun]', '[AUTH] failed', (error || {}).message || `cannot GET /users/${token}`); |
|
|
|