Skip to content

Commit

Permalink
feat/#507: "refreshToken" 문자열 상수화
Browse files Browse the repository at this point in the history
  • Loading branch information
LJH098 authored and hwangdaesun committed Oct 9, 2024
1 parent abcf247 commit 4bfde62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.gaebaljip.exceed.common.EatCeedStaticMessage;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -75,21 +76,21 @@ public ApiResponse<ApiResponse.CustomBody<Void>> logout(
}

private void setCookie(HttpServletResponse response, String refreshToken) {
Cookie cookie = new Cookie("refreshToken", refreshToken);
Cookie cookie = new Cookie(EatCeedStaticMessage.REFRESH_TOKEN, refreshToken);
cookie.setHttpOnly(true);
cookie.setSecure(true);
response.addCookie(cookie);
}

private void deleteRefreshCookie(HttpServletResponse response) {
Cookie cookie = new Cookie("refreshToken", null);
Cookie cookie = new Cookie(EatCeedStaticMessage.REFRESH_TOKEN, null);
cookie.setMaxAge(0);
response.addCookie(cookie);
}

private Cookie getCookie(Cookie[] cookies) {
for (Cookie cookie : cookies) {
if (cookie.getName().equals("refreshToken")) {
if (cookie.getName().equals(EatCeedStaticMessage.REFRESH_TOKEN)) {
return cookie;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
public class EatCeedStaticMessage {
public static final String REDIS_AUTO_COMPLETE_KEY = "autoComplete";
public static final String REDIS_REFRESH_TOKEN_KEY = "refresh_";

public static final String REFRESH_TOKEN = "refreshToken";
}

0 comments on commit 4bfde62

Please sign in to comment.