Skip to content

Commit 973e592

Browse files
committed
Add domain to all cookie actions
1 parent de2df70 commit 973e592

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

helpers/authHandling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ class AuthHandling {
99
const split_token = token.split(".");
1010

1111
// Javascript Enabled Cookie - Full JWT
12-
queryRes.cookie("sid", token, {httpOnly: false, maxAge: 86400000, secure: true, sameSite: "None", path: '/', domain: "twesche.com"});
12+
queryRes.cookie("sid", token, {httpOnly: false, maxAge: 86400000, secure: true, sameSite: "None", path: '/', domain: ".twesche.com"});
1313
// queryRes.cookie("sid", token, {httpOnly: false, maxAge: 86400000, path: '/', domain: "twesche.com"});
1414

1515
// HTTP Only Cookie - JWT Signature Only
16-
queryRes.cookie("_sid", split_token[2], {httpOnly: true, maxAge: 86400000, secure: true, sameSite: "None", path: '/', domain: "twesche.com"});
16+
queryRes.cookie("_sid", split_token[2], {httpOnly: true, maxAge: 86400000, secure: true, sameSite: "None", path: '/', domain: ".twesche.com"});
1717
// queryRes.cookie("_sid", split_token[2], {httpOnly: true, maxAge: 86400000, path: '/', domain: "twesche.com"});
1818
}
1919

routes/merchants.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ merchantRouter.post('/about', ensureIsMerchant, async (req, res, next) => {
5757

5858
merchantRouter.get("/logout", async (req, res, next) => {
5959
try {
60-
res.clearCookie('sid');
61-
res.clearCookie('_sid');
60+
res.clearCookie('sid', {domain: '.twesche.com'});
61+
res.clearCookie('_sid', {domain: '.twesche.com'});
6262

6363
return res.json({"message": "Logout successful."})
6464
} catch (error) {
@@ -239,8 +239,8 @@ merchantRouter.delete("/delete", ensureIsMerchant, async (req, res, next) => {
239239
throw new ExpressError("Unable to delete target user account", 404);
240240
}
241241

242-
res.clearCookie('sid');
243-
res.clearCookie('_sid');
242+
res.clearCookie('sid', {domain: '.twesche.com'});
243+
res.clearCookie('_sid', {domain: '.twesche.com'});
244244
return res.json({message: "Your account has been deleted."})
245245
} catch (error) {
246246
return next(error);

routes/users.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ userRouter.delete("/delete", ensureIsUser, async (req, res, next) => {
102102
throw new ExpressError("Unable to delete target user account", 404);
103103
}
104104

105-
res.clearCookie('sid', {domain: 'twesche.com'});
106-
res.clearCookie('_sid', {domain: 'twesche.com'});
105+
res.clearCookie('sid', {domain: '.twesche.com'});
106+
res.clearCookie('_sid', {domain: '.twesche.com'});
107107
return res.json({message: "Your account has been deleted."})
108108
} catch (error) {
109109
return next(error);
@@ -119,8 +119,8 @@ userRouter.delete("/delete", ensureIsUser, async (req, res, next) => {
119119

120120
userRouter.get("/logout", async (req, res, next) => {
121121
try {
122-
res.clearCookie('sid', {domain: 'twesche.com'});
123-
res.clearCookie('_sid', {domain: 'twesche.com'});
122+
res.clearCookie('sid', {domain: '.twesche.com'});
123+
res.clearCookie('_sid', {domain: '.twesche.com'});
124124

125125
return res.json({"message": "Logout successful."})
126126
} catch (error) {

0 commit comments

Comments
 (0)