Skip to content

Commit

Permalink
Merge pull request #12 from Murakano/dev
Browse files Browse the repository at this point in the history
♻️ 쿠키 sameSite 옵션 설정
  • Loading branch information
jjikky authored Jun 29, 2024
2 parents 9816e65 + 8389e19 commit 103f3ea
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/routes/user/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ exports.localLogin = async (req, res, next) => {

const accessToken = generateAccessToken(user);
const refreshToken = generateRefreshToken(user);
res.cookie('accessToken', accessToken, { httpOnly: false, maxAge: 10 * 60 * 1000 });
res.cookie('refreshToken', refreshToken, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000 });

// production 환경에서는 secure 필요 혹은 LAX로 변경, 쿠키와 토큰 주기 변경
res.cookie('accessToken', accessToken, { httpOnly: false, maxAge: 10 * 60 * 1000, sameSite: 'None' });
res.cookie('refreshToken', refreshToken, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000, sameSite: 'None' });

return sendResponse.ok(res, {
message: SucesssMessage.LOGIN_SUCCESSS,
Expand Down Expand Up @@ -130,8 +132,8 @@ exports.kakaoLogin = async (req, res) => {

const accessToken = generateAccessToken(user);
const refreshToken = generateRefreshToken(user);
res.cookie('accessToken', accessToken, { httpOnly: false, maxAge: 10 * 60 * 1000 });
res.cookie('refreshToken', refreshToken, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000 });
res.cookie('accessToken', accessToken, { httpOnly: false, maxAge: 10 * 60 * 1000, sameSite: 'None' });
res.cookie('refreshToken', refreshToken, { httpOnly: true, maxAge: 24 * 60 * 60 * 1000, sameSite: 'None' });

sendResponse.ok(res, {
message: SucesssMessage.LOGIN_SUCCESSS,
Expand Down

0 comments on commit 103f3ea

Please sign in to comment.