Check jwt expire date

This commit is contained in:
Takeshi Kimata
2024-05-25 19:50:01 +09:00
parent 25402bd3ba
commit 4092b14f3c
4 changed files with 16 additions and 4 deletions

View File

@@ -29,7 +29,9 @@ module.exports = function (sequelize) {
const accessToken = jwt.sign({ userId: user.id }, secretKey, {
expiresIn: '1h',
});
res.status(200).json({ access_token: accessToken, user });
const expiresAt = Date.now() + 3600 * 1000; // expire date(ms)
res.status(200).json({ access_token: accessToken, expires_at: expiresAt, user });
} catch (error) {
console.error(error);
res.status(500).send('Sign up failed');

View File

@@ -31,9 +31,10 @@ module.exports = function (sequelize) {
const accessToken = jwt.sign({ userId: user.id }, secretKey, {
expiresIn: '1h',
});
const expiresAt = Date.now() + 3600 * 1000; // expire date(ms)
user.password = undefined;
res.status(200).json({ access_token: accessToken, user });
res.status(200).json({ access_token: accessToken, expires_at: expiresAt, user });
} catch (error) {
console.error(error);
res.status(500).send('Sign up failed');