Skip to content

Commit

Permalink
Merge pull request #13 from Murakano/dev
Browse files Browse the repository at this point in the history
♻️ cookie secure설정 추가
  • Loading branch information
jjikky authored Jun 29, 2024
2 parents 103f3ea + e3500d7 commit 35be450
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/routes/user/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,18 @@ exports.localLogin = async (req, res, next) => {
const refreshToken = generateRefreshToken(user);

// 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' });
res.cookie('accessToken', accessToken, {
httpOnly: false,
maxAge: 10 * 60 * 1000,
sameSite: 'None',
secure: true,
});
res.cookie('refreshToken', refreshToken, {
httpOnly: true,
maxAge: 24 * 60 * 60 * 1000,
sameSite: 'None',
secure: true,
});

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

const accessToken = generateAccessToken(user);
const refreshToken = generateRefreshToken(user);
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' });
res.cookie('accessToken', accessToken, {
httpOnly: false,
maxAge: 10 * 60 * 1000,
sameSite: 'None',
secure: true,
});
res.cookie('refreshToken', refreshToken, {
httpOnly: true,
maxAge: 24 * 60 * 60 * 1000,
sameSite: 'None',
secure: true,
});

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

0 comments on commit 35be450

Please sign in to comment.