Skip to content

Commit 9100e60

Browse files
authored
feat: add support for redirecting admins to custom dashboards view
Hi there! This pull request adds an `onLoginSuccessHook` middleware function to the web app to support a feature in which users can be redirected to their custom dashboard views in the app (or other pages such as account / settings / etc). I also added a `console.log()` to audit logged-in state for tampering threat model.
1 parent d240896 commit 9100e60

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

routes/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ var fs = require('fs');
1919
// prototype-pollution
2020
var _ = require('lodash');
2121

22+
function onLoginSuccessHook(redirectPage, session, username, res) {
23+
session.loggedIn = 1
24+
25+
// Log the login action for audit
26+
console.log(`User logged in: ${username}`)
27+
28+
if (redirectPage) {
29+
return res.redirect(redirectPage)
30+
} else {
31+
return res.redirect('/admin')
32+
}
33+
}
34+
2235
exports.index = function (req, res, next) {
2336
Todo.
2437
find({}).

0 commit comments

Comments
 (0)