Skip to content

Commit

Permalink
feat: refresh token api 방어 코드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
syoung125 committed Oct 23, 2023
1 parent b5ba20c commit dc84f39
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pages/api/refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ export default async function handler(
validateStatus: null,
});

setAccessToken(response.headers[ACCESS_TOKEN_KEY], { req, res });
setRefreshToken(response.headers[REFRESH_TOKEN_KEY], { req, res });
const newAccessToken = response.headers[ACCESS_TOKEN_KEY];
const newRefreshToken = response.headers[REFRESH_TOKEN_KEY];

if (!newAccessToken || !newRefreshToken) {
throw new Error('Invalid tokens.');
}

setAccessToken(newAccessToken, { req, res });
setRefreshToken(newRefreshToken, { req, res });

res.status(200).json({ result: true });
} catch (err) {
Expand Down

0 comments on commit dc84f39

Please sign in to comment.