mbkauthe 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/main.js +12 -3
- package/lib/validateSessionAndRole.js +3 -0
- package/package.json +1 -1
package/lib/main.js
CHANGED
|
@@ -25,7 +25,6 @@ try {
|
|
|
25
25
|
} catch (error) {
|
|
26
26
|
console.log("Error parsing COOKIE_EXPIRE_TIME:", error);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
28
|
// Enable CORS for subdomains
|
|
30
29
|
router.use((req, res, next) => {
|
|
31
30
|
const origin = req.headers.origin;
|
|
@@ -122,7 +121,9 @@ router.post("/mbkauthe/api/terminateAllSessions", authenticate(mbkautheVar.Main_
|
|
|
122
121
|
req.session.destroy((err) => {
|
|
123
122
|
if (err) {
|
|
124
123
|
console.log("Error destroying session:", err);
|
|
125
|
-
return res
|
|
124
|
+
return res
|
|
125
|
+
.status(500)
|
|
126
|
+
.json({ success: false, message: "Failed to terminate sessions" });
|
|
126
127
|
}
|
|
127
128
|
console.log("All sessions terminated successfully");
|
|
128
129
|
res.status(200).json({
|
|
@@ -184,7 +185,6 @@ router.post("/mbkauthe/api/login", async (req, res) => {
|
|
|
184
185
|
// Query to check if the username exists
|
|
185
186
|
const userQuery = `SELECT * FROM "Users" WHERE "UserName" = $1`;
|
|
186
187
|
const userResult = await dblogin.query(userQuery, [username]);
|
|
187
|
-
console.log("User query result:", userResult.rows); // Log user query result
|
|
188
188
|
|
|
189
189
|
if (userResult.rows.length === 0) {
|
|
190
190
|
console.log(`Username does not exist: ${username}`);
|
|
@@ -259,6 +259,15 @@ router.post("/mbkauthe/api/login", async (req, res) => {
|
|
|
259
259
|
sessionId,
|
|
260
260
|
};
|
|
261
261
|
|
|
262
|
+
res.cookie("sessionId", sessionId, {
|
|
263
|
+
maxAge: COOKIE_EXPIRE_TIME,
|
|
264
|
+
path: '/',
|
|
265
|
+
DOMAIN: mbkautheVar.IS_DEPLOYED === 'true' ? `.${mbkautheVar.DOMAIN}` : undefined,
|
|
266
|
+
secure: mbkautheVar.IS_DEPLOYED === 'true',
|
|
267
|
+
});
|
|
268
|
+
console.log(req.session.user);
|
|
269
|
+
|
|
270
|
+
|
|
262
271
|
console.log(`User "${username}" logged in successfully`);
|
|
263
272
|
res.status(200).json({
|
|
264
273
|
success: true,
|
|
@@ -25,6 +25,9 @@ async function validateSession(req, res, next) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (!req.session.user) {
|
|
28
|
+
|
|
29
|
+
console.log("User not authenticated");
|
|
30
|
+
console.log(req.session.user);
|
|
28
31
|
return res.render("templates/Error/NotLoggedIn.handlebars", {
|
|
29
32
|
currentUrl: req.originalUrl,
|
|
30
33
|
});
|