fix(auth): build cookies before writing headers

This commit is contained in:
Kroytz committed 2026-07-19 10:34:46 +08:00
1 parent 6ffdbcb3d7
commit 700db68d19
1 file changed
+4 -4
@@ -204,13 +204,13 @@ public class AuthController {
}
private void writeTokenCookies(HttpServletResponse response, AuthLoginRespVO token) {
response.addHeader(HttpHeaders.SET_COOKIE, tokenCookie(ACCESS_TOKEN_COOKIE, token.getAccessToken()).toString());
response.addHeader(HttpHeaders.SET_COOKIE, tokenCookie(REFRESH_TOKEN_COOKIE, token.getRefreshToken()).toString());
response.addHeader(HttpHeaders.SET_COOKIE, tokenCookie(ACCESS_TOKEN_COOKIE, token.getAccessToken()).build().toString());
response.addHeader(HttpHeaders.SET_COOKIE, tokenCookie(REFRESH_TOKEN_COOKIE, token.getRefreshToken()).build().toString());
}
private void clearTokenCookies(HttpServletResponse response) {
response.addHeader(HttpHeaders.SET_COOKIE, tokenCookie(ACCESS_TOKEN_COOKIE, "").maxAge(Duration.ZERO).toString());
response.addHeader(HttpHeaders.SET_COOKIE, tokenCookie(REFRESH_TOKEN_COOKIE, "").maxAge(Duration.ZERO).toString());
response.addHeader(HttpHeaders.SET_COOKIE, tokenCookie(ACCESS_TOKEN_COOKIE, "").maxAge(Duration.ZERO).build().toString());
response.addHeader(HttpHeaders.SET_COOKIE, tokenCookie(REFRESH_TOKEN_COOKIE, "").maxAge(Duration.ZERO).build().toString());
}
private ResponseCookie.ResponseCookieBuilder tokenCookie(String name, String value) {