fix(auth): return JSON 401 for API sessions and harden cross-site cookies
This commit is contained in:
4
index.js
4
index.js
@@ -240,7 +240,7 @@ const webPushEmail = process.env.WEB_PUSH_EMAIL;
|
||||
webPush.setVapidDetails('mailto:' + webPushEmail, publicVapidKey, privateVapidKey);
|
||||
|
||||
|
||||
const { cookiesOptions } = require('./config/cookiesOptions');
|
||||
const { getCookiesOptions } = require('./config/cookiesOptions');
|
||||
const { client_logger } = require('./utils/analyticsLogger.js');
|
||||
const { getSessionId, getUserId, getProfileId } = require('./utils/sessionUtils.js');
|
||||
|
||||
@@ -410,7 +410,7 @@ DB.getDB.then((DB) => {
|
||||
return res.status(403).json({ status: "Profile does not belong to the logged-in user" });
|
||||
}
|
||||
// Update active profile cookie
|
||||
res.cookie('profile_id', profile._id, cookiesOptions);
|
||||
res.cookie('profile_id', profile._id, getCookiesOptions(req));
|
||||
return res.json({ status: "ok", profile });
|
||||
} catch (error) {
|
||||
console.error("Error changing profile:", error);
|
||||
|
||||
Reference in New Issue
Block a user