|  |  | @ -72,24 +72,34 @@ let authorizeToken = async function (ctx, token) { | 
			
		
	
		
			
				
					|  |  |  |    if (token && tokenFormatRegexp.test(token)) { | 
			
		
	
		
			
				
					|  |  |  |       try { | 
			
		
	
		
			
				
					|  |  |  |          console.log(`DurationCalc: auth 1 用时 ${moment().diff(startTime, 'milliseconds')}`); | 
			
		
	
		
			
				
					|  |  |  |          const authorizeRes = await ctx.app.fs.emisRequest.get('authorize', { | 
			
		
	
		
			
				
					|  |  |  |             query: { token } | 
			
		
	
		
			
				
					|  |  |  |          }) | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |          const expired = await ctx.redis.hget(token, 'expired'); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |          // const authorizeRes = await ctx.app.fs.emisRequest.get('authorize', {
 | 
			
		
	
		
			
				
					|  |  |  |          //    query: { token }
 | 
			
		
	
		
			
				
					|  |  |  |          // })
 | 
			
		
	
		
			
				
					|  |  |  |          // const { userInfo, expired } = authorizeRes;
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |          console.log(`DurationCalc: auth 2 用时 ${moment().diff(startTime, 'milliseconds')}`); | 
			
		
	
		
			
				
					|  |  |  |          const { userInfo, expired } = authorizeRes; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |          // TODO 从项企 clickhouse 数据库中查 token 并更新
 | 
			
		
	
		
			
				
					|  |  |  |          if (expired && moment().valueOf() <= moment(expired).valueOf()) { | 
			
		
	
		
			
				
					|  |  |  |             const pomsUser = await ctx.app.fs.dc.models.User.findOne({ | 
			
		
	
		
			
				
					|  |  |  |                where: { | 
			
		
	
		
			
				
					|  |  |  |                   pepUserId: userInfo.id | 
			
		
	
		
			
				
					|  |  |  |                } | 
			
		
	
		
			
				
					|  |  |  |             }) || {} | 
			
		
	
		
			
				
					|  |  |  |             const userInfo = JSON.parse(await ctx.redis.hmget(token, 'userInfo')); | 
			
		
	
		
			
				
					|  |  |  |             const { pomsUserInfo: pomsUser } = userInfo | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             // const pomsUser = await ctx.app.fs.dc.models.User.findOne({
 | 
			
		
	
		
			
				
					|  |  |  |             //    where: {
 | 
			
		
	
		
			
				
					|  |  |  |             //       pepUserId: userInfo.id
 | 
			
		
	
		
			
				
					|  |  |  |             //    }
 | 
			
		
	
		
			
				
					|  |  |  |             // }) || {}
 | 
			
		
	
		
			
				
					|  |  |  |              | 
			
		
	
		
			
				
					|  |  |  |             console.log(`DurationCalc: auth 3 用时 ${moment().diff(startTime, 'milliseconds')}`); | 
			
		
	
		
			
				
					|  |  |  |             rslt = { | 
			
		
	
		
			
				
					|  |  |  |                'authorized': userInfo.authorized, | 
			
		
	
		
			
				
					|  |  |  |                'resources': (userInfo || {}).resources || [], | 
			
		
	
		
			
				
					|  |  |  |             }; | 
			
		
	
		
			
				
					|  |  |  |             ctx.fs.api.userId = pomsUser.id; | 
			
		
	
		
			
				
					|  |  |  |             ctx.fs.api.userInfo = pomsUser.dataValues; | 
			
		
	
		
			
				
					|  |  |  |             ctx.fs.api.userInfo = pomsUser; | 
			
		
	
		
			
				
					|  |  |  |             ctx.fs.api.pepUserId = userInfo.id; | 
			
		
	
		
			
				
					|  |  |  |             ctx.fs.api.pepUserInfo = userInfo; | 
			
		
	
		
			
				
					|  |  |  |             ctx.fs.api.token = token; | 
			
		
	
	
		
			
				
					|  |  | 
 |