|  |  | @ -71,9 +71,17 @@ 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'); | 
			
		
	
		
			
				
					|  |  |  |             if (expired && moment().valueOf() <= moment(expired).valueOf()) { | 
			
		
	
		
			
				
					|  |  |  |                 const userInfo = JSON.parse(await ctx.redis.hget(token, 'userInfo')); | 
			
		
	
		
			
				
					|  |  |  |             // const expired = await ctx.redis.hget(token, 'expired');
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             const 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 || [], | 
			
		
	
	
		
			
				
					|  |  | @ -84,7 +92,7 @@ let authorizeToken = async function (ctx, token) { | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } catch (err) { | 
			
		
	
		
			
				
					|  |  |  |             const { error } = err.response || {}; | 
			
		
	
		
			
				
					|  |  |  |             ctx.fs.logger.log('[anxinyun]', '[AUTH] failed', (error || {}).message || `cannot GET /users/${token}`); | 
			
		
	
		
			
				
					|  |  |  |             ctx.fs.logger.log('[IOT AUTH]', '[AUTH] failed', (error || {}).message || `${token}`); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  |     return rslt; | 
			
		
	
	
		
			
				
					|  |  | 
 |