diff options
author | Akshay <[email protected]> | 2024-11-14 13:44:33 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2024-11-14 13:44:33 +0000 |
commit | e2c410822ad8aea8ec702cef6bba5de352b8c73d (patch) | |
tree | a4eed7c8a57ef995300c5b31946456e94192caa8 /src/routes/index.js | |
parent | 5c78a2310dc19869d36da1b630801cb9096f7d58 (diff) |
everything expires in 5 days
Diffstat (limited to 'src/routes/index.js')
-rw-r--r-- | src/routes/index.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/routes/index.js b/src/routes/index.js index f5d679c..1141009 100644 --- a/src/routes/index.js +++ b/src/routes/index.js | |||
@@ -150,12 +150,12 @@ router.post("/register", async (req, res) => { | |||
150 | hashedPassword, | 150 | hashedPassword, |
151 | }); | 151 | }); |
152 | const id = insertedRecord.lastInsertRowid; | 152 | const id = insertedRecord.lastInsertRowid; |
153 | const token = jwt.sign({ username, id }, JWT_KEY, { expiresIn: "100h" }); | 153 | const token = jwt.sign({ username, id }, JWT_KEY, { expiresIn: "5d" }); |
154 | res | 154 | res |
155 | .status(200) | 155 | .status(200) |
156 | .cookie("auth_token", token, { | 156 | .cookie("auth_token", token, { |
157 | httpOnly: true, | 157 | httpOnly: true, |
158 | maxAge: 2 * 24 * 60 * 60 * 1000, | 158 | maxAge: 5 * 24 * 60 * 60 * 1000, |
159 | }) | 159 | }) |
160 | .redirect("/"); | 160 | .redirect("/"); |
161 | } catch (err) { | 161 | } catch (err) { |
@@ -177,12 +177,12 @@ router.post("/login", async (req, res) => { | |||
177 | .get({ username }); | 177 | .get({ username }); |
178 | if (user && (await Bun.password.verify(password, user.password_hash))) { | 178 | if (user && (await Bun.password.verify(password, user.password_hash))) { |
179 | const token = jwt.sign({ username, id: user.id }, JWT_KEY, { | 179 | const token = jwt.sign({ username, id: user.id }, JWT_KEY, { |
180 | expiresIn: "1h", | 180 | expiresIn: "5d", |
181 | }); | 181 | }); |
182 | res | 182 | res |
183 | .cookie("auth_token", token, { | 183 | .cookie("auth_token", token, { |
184 | httpOnly: true, | 184 | httpOnly: true, |
185 | maxAge: 2 * 24 * 60 * 60 * 1000, | 185 | maxAge: 5 * 24 * 60 * 60 * 1000, |
186 | }) | 186 | }) |
187 | .redirect(req.query.redirect || "/"); | 187 | .redirect(req.query.redirect || "/"); |
188 | } else { | 188 | } else { |