Chain login to use getSessionUser to fill all the correct fields

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2018-10-11 20:38:19 -07:00
parent 873efac52f
commit 734fc13967

View File

@ -287,11 +287,12 @@ router.post("/login", function(req, res) {
/* We use LDAP as the primary authenticator; if the user is not /* We use LDAP as the primary authenticator; if the user is not
* found there, we look the user up in the site-specific user database */ * found there, we look the user up in the site-specific user database */
return ldapPromise(username, password).then(function(user) { return ldapPromise(username, password).then(function(ldap) {
user.name = user.displayName; let user = {};
user.username = user.uid; user.name = ldap.displayName;
user.username = ldap.uid;
user.id = "LDAP"; user.id = "LDAP";
user.mail = user.mail; user.mail = ldap.mail;
user.authenticated = 1; user.authenticated = 1;
user.mailVerified = 1; user.mailVerified = 1;
req.session.userId = "LDAP"; req.session.userId = "LDAP";
@ -332,9 +333,9 @@ router.post("/login", function(req, res) {
console.log(message); console.log(message);
} }
delete user.id; return getSessionUser(req).then(function(user) {
return res.status(200).send(user);
return res.status(200).send(user); });
}); });
}); });