|
|
@@ -2,6 +2,7 @@ package com.nju.edu.pay.web;
|
|
|
|
|
|
import com.nju.edu.pay.util.jwt.JWTUtil;
|
|
|
import com.nju.edu.pay.web.annotation.RootAllowed;
|
|
|
+import com.nju.edu.pay.web.exception.AuthException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.method.HandlerMethod;
|
|
|
import org.springframework.web.servlet.HandlerInterceptor;
|
|
|
@@ -25,10 +26,14 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
|
|
|
HandlerMethod handlerMethod=(HandlerMethod)object;
|
|
|
Method method=handlerMethod.getMethod();
|
|
|
if (method.isAnnotationPresent(RootAllowed.class)) {
|
|
|
- RootAllowed passToken = method.getAnnotation(RootAllowed.class);
|
|
|
- if (passToken.required()) {
|
|
|
+ RootAllowed rootAllowed = method.getAnnotation(RootAllowed.class);
|
|
|
+ if (rootAllowed.required()) {
|
|
|
String token=httpServletRequest.getHeader("Authorization");
|
|
|
- return jwtUtil.verifyToken(token);
|
|
|
+ if(jwtUtil.verifyToken(token)){
|
|
|
+ return true;
|
|
|
+ }else{
|
|
|
+ throw new AuthException(401,"权限验证失败");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return true;
|