Blumonilr 6 лет назад
Родитель
Сommit
469e9939c3

+ 2 - 5
src/main/java/com/nju/edu/pay/controller/api/AuthController.java

@@ -7,10 +7,7 @@ import com.nju.edu.pay.web.response.ErrorResponse;
 import com.nju.edu.pay.web.response.Response;
 import com.nju.edu.pay.web.response.SuccessResponse;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 @RestController
 @RequestMapping("/api/auth")
@@ -30,7 +27,7 @@ public class AuthController {
         String phone= loginDTO.getPhone();
         String password=loginDTO.getPassword();
         if (phone.equals(rootProperties.getPhone())&& password.equals(rootProperties.getPassword())){
-            return new SuccessResponse(jwtUtil.createToken(rootProperties.getName()));
+            return new SuccessResponse("Bear "+jwtUtil.createToken(rootProperties.getName()));
         }else {
             return new ErrorResponse(500,"登录失败");
         }

+ 1 - 0
src/main/java/com/nju/edu/pay/controller/api/TradeController.java

@@ -5,6 +5,7 @@ import com.nju.edu.pay.web.annotation.RootAllowed;
 import com.nju.edu.pay.web.response.Response;
 import com.nju.edu.pay.web.response.SuccessResponse;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;

+ 1 - 1
src/main/java/com/nju/edu/pay/web/AuthenticationInterceptor.java

@@ -28,7 +28,7 @@ public class AuthenticationInterceptor implements HandlerInterceptor {
         if (method.isAnnotationPresent(RootAllowed.class)) {
             RootAllowed rootAllowed = method.getAnnotation(RootAllowed.class);
             if (rootAllowed.required()) {
-                String token=httpServletRequest.getHeader("Authorization");
+                String token=httpServletRequest.getHeader("Authorization").split(" ")[1];
                 if(jwtUtil.verifyToken(token)){
                     return true;
                 }else{