Skip to content
Snippets Groups Projects
Commit 1cd80bb9 authored by nahyun's avatar nahyun
Browse files

add(app.js): refresh-token 함수-사용자 사용시엔 refresh token 발급

parent db854370
No related branches found
No related tags found
No related merge requests found
......@@ -300,6 +300,31 @@ app.post('/signup', async (req, res) => {
}
});
//토큰 갱신
app.post('/refresh-token', authenticateToken, (req, res) => {
try {
console.log('토큰 갱신 요청 받음:', {
사용자: req.user.email,
요청시간: new Date().toLocaleString()
});
const newToken = jwt.sign(
{
userId: req.user.userId,
email: req.user.email,
name: req.user.name
},
secretKey,
{ expiresIn: process.env.TOKEN_EXPIRATION }
);
console.log('토큰 갱신 성공, 새로운 토큰:', newToken);
res.json({ token: newToken });
} catch (error) {
console.error('토큰 갱신 실패:', error);
res.status(500).json({ message: '토큰 갱신 실패' });
}
});
const server = http.createServer(app);
const wss = new WebSocketServer(server);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment