|
|
|
@ -44,7 +44,31 @@ public class TestController extends BaseController { |
|
|
|
|
|
|
|
|
|
|
|
//登陆逻辑
|
|
|
|
//登陆逻辑
|
|
|
|
@GetMapping("/doLogin") |
|
|
|
public String Test(HttpServletResponse response){ |
|
|
|
StpUtil.login(6);//登录
|
|
|
|
// 获取当前登录的Token(假设你使用的是默认的Token名称 "satoken")
|
|
|
|
String token = StpUtil.getTokenValue(); |
|
|
|
|
|
|
|
// 创建一个HttpOnly Cookie
|
|
|
|
Cookie cookie = new Cookie("satoken", token); |
|
|
|
cookie.setHttpOnly(true); // 设置为HttpOnly,防止JavaScript访问
|
|
|
|
cookie.setSecure(true); // 如果使用HTTPS,则设置为true
|
|
|
|
cookie.setPath("/"); // 设置Cookie的作用路径
|
|
|
|
cookie.setMaxAge(5 * 60 * 60); // Token有效期为7天,单位为秒
|
|
|
|
// 手动设置SameSite属性
|
|
|
|
response.setHeader("Set-Cookie", "satoken=" + token + "; Path=/; Max-Age=" + (7 * 24 * 60 * 60) + "; Secure; HttpOnly; SameSite=None"); |
|
|
|
|
|
|
|
// 将Cookie添加到响应中
|
|
|
|
response.addCookie(cookie); |
|
|
|
return "成功登录"; |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/test") |
|
|
|
public Long TT(){ |
|
|
|
return getUserId(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//图谱的逻辑
|
|
|
|
|