fix(temp): expiry
This commit is contained in:
@@ -44,9 +44,7 @@ router.post("/register", async (req, res) => {
|
|||||||
return res.status(500).send("Internal Server Error");
|
return res.status(500).send("Internal Server Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = jwt.sign({ id: user.id }, process.env.JWT_SECRET as string, {
|
const token = jwt.sign({ id: user.id }, process.env.JWT_SECRET as string);
|
||||||
expiresIn: "12h",
|
|
||||||
});
|
|
||||||
user.password = undefined as unknown as string;
|
user.password = undefined as unknown as string;
|
||||||
res.cookie("token", token, {
|
res.cookie("token", token, {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
@@ -78,9 +76,7 @@ router.post("/login", async (req, res) => {
|
|||||||
const match = await comparePassword(password, user.password);
|
const match = await comparePassword(password, user.password);
|
||||||
if (!match) return res.status(400).send("Invalid email or password");
|
if (!match) return res.status(400).send("Invalid email or password");
|
||||||
|
|
||||||
const token = jwt.sign({ id: user?.id }, process.env.JWT_SECRET as string, {
|
const token = jwt.sign({ id: user?.id }, process.env.JWT_SECRET as string);
|
||||||
expiresIn: "12h",
|
|
||||||
});
|
|
||||||
|
|
||||||
// return user and token to client, exclude hashed password
|
// return user and token to client, exclude hashed password
|
||||||
if (user) {
|
if (user) {
|
||||||
@@ -371,8 +367,7 @@ router.get(
|
|||||||
// Generate JWT token for session
|
// Generate JWT token for session
|
||||||
const jwtToken = jwt.sign(
|
const jwtToken = jwt.sign(
|
||||||
{ userId: user.id },
|
{ userId: user.id },
|
||||||
process.env.JWT_SECRET as string,
|
process.env.JWT_SECRET as string
|
||||||
{ expiresIn: "12h" }
|
|
||||||
);
|
);
|
||||||
res.cookie("token", jwtToken, { httpOnly: true });
|
res.cookie("token", jwtToken, { httpOnly: true });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user