Browse Source

去掉时间测算提示

dev
巴林闲侠 2 years ago
parent
commit
65702d3fef
  1. 4
      api/app/lib/controllers/organization/index.js
  2. 5
      api/app/lib/middlewares/authenticator.js

4
api/app/lib/controllers/organization/index.js

@ -7,14 +7,10 @@ async function allDeps (ctx) {
const { redis } = ctx.app const { redis } = ctx.app
const start = moment() const start = moment()
let depRes = await redis.get('allDepartments') let depRes = await redis.get('allDepartments')
console.log(`DurationCalc: 1 用时 ${moment().diff(start, 'milliseconds')}`);
if (depRes) { if (depRes) {
depRes = JSON.parse(depRes) depRes = JSON.parse(depRes)
console.log(`DurationCalc: 2 用时 ${moment().diff(start, 'milliseconds')}`);
depRes = depRes.departments depRes = depRes.departments
console.log(`DurationCalc: 3 用时 ${moment().diff(start, 'milliseconds')}`);
} }
console.log(`DurationCalc: 4 用时 ${moment().diff(start, 'milliseconds')}`);
ctx.status = 200; ctx.status = 200;
ctx.body = depRes || [] ctx.body = depRes || []
} catch (error) { } catch (error) {

5
api/app/lib/middlewares/authenticator.js

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

Loading…
Cancel
Save