|
|
@ -1,9 +1,11 @@ |
|
|
|
package com.iflytop.nuclear.filter; |
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
import com.iflytop.nuclear.entity.JwtUser; |
|
|
|
import com.iflytop.nuclear.model.Account; |
|
|
|
import com.iflytop.nuclear.utils.JwtTokenUtils; |
|
|
|
import com.iflytop.nuclear.utils.ResponseData; |
|
|
|
import org.springframework.security.authentication.AuthenticationManager; |
|
|
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
|
|
|
import org.springframework.security.core.Authentication; |
|
|
@ -68,6 +70,10 @@ public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilte |
|
|
|
// 但是这里创建的token只是单纯的token |
|
|
|
// 按照jwt的规定,最后请求的时候应该是 `Bearer token` |
|
|
|
response.setHeader("token", JwtTokenUtils.TOKEN_PREFIX + token); |
|
|
|
JSONObject res = new JSONObject(); |
|
|
|
res.put("token", JwtTokenUtils.TOKEN_PREFIX + token); |
|
|
|
res.put("username", jwtUser.getUsername()); |
|
|
|
response.getWriter().write(JSONObject.toJSONString(ResponseData.success(res))); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|