mirror of
				https://github.com/suyiiyii/SIMS.git
				synced 2025-11-04 07:24:53 +08:00 
			
		
		
		
	增强JWT拦截器异常处理
新增异常处理,专门针对无法识别的token异常,提升错误提示的准确性。当token验证失败时,现在将抛出一个具体的"token验证失败,请重新登录"错误,以区别于登录过期错误。
This commit is contained in:
		
							parent
							
								
									94bf792cd2
								
							
						
					
					
						commit
						28f5b146d8
					
				@ -48,6 +48,8 @@ public class JwtInterceptor implements HandlerInterceptor {
 | 
			
		||||
            }
 | 
			
		||||
        } catch (TokenExpiredException e) {
 | 
			
		||||
            throw new ServiceException("401", "登录已过期,请重新登录");
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            throw new ServiceException("401", "token验证失败,请重新登录");
 | 
			
		||||
        }
 | 
			
		||||
        // 获取 token 中的 user id
 | 
			
		||||
        Integer userId = Integer.parseInt(Objects.requireNonNull(JwtUtils.extractUserId(token)));
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user