token 验证
This commit is contained in:
		
							parent
							
								
									dedaf3e0a3
								
							
						
					
					
						commit
						41dde067d2
					
				| 
						 | 
				
			
			@ -12,6 +12,8 @@ namespace LY.App.MiddleWare
 | 
			
		|||
            _redis = redisHelper;
 | 
			
		||||
        }
 | 
			
		||||
        public async Task InvokeAsync(HttpContext context, RequestDelegate next)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
                // 排除不需要Token验证的API
 | 
			
		||||
                if (IsExcludedPath(context.Request.Path))
 | 
			
		||||
| 
						 | 
				
			
			@ -49,6 +51,13 @@ namespace LY.App.MiddleWare
 | 
			
		|||
                    await context.Response.WriteAsync("Unauthorized: Invalid Token");
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex)
 | 
			
		||||
            {
 | 
			
		||||
                context.Response.StatusCode = 401;
 | 
			
		||||
                await context.Response.WriteAsync("Unauthorized: Invalid Token");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// 这是放不需要过滤的api地址
 | 
			
		||||
        /// </summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue