Restructure LDAP auth so it works with restricted albums
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
2800f53076
commit
859fb9d748
@ -125,7 +125,6 @@ const getSessionUser = function(req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let user = results[0];
|
let user = results[0];
|
||||||
req.user = user;
|
|
||||||
|
|
||||||
if (!user.mailVerified) {
|
if (!user.mailVerified) {
|
||||||
user.restriction = user.restriction || "Email address not verified.";
|
user.restriction = user.restriction || "Email address not verified.";
|
||||||
@ -140,6 +139,8 @@ const getSessionUser = function(req) {
|
|||||||
return user;
|
return user;
|
||||||
});
|
});
|
||||||
}).then(function(user) {
|
}).then(function(user) {
|
||||||
|
req.user = user;
|
||||||
|
|
||||||
/* If the user already has a restriction, or there are no album user restrictions,
|
/* If the user already has a restriction, or there are no album user restrictions,
|
||||||
* return the user to the next promise */
|
* return the user to the next promise */
|
||||||
if (user.restriction || !config.has("restrictions")) {
|
if (user.restriction || !config.has("restrictions")) {
|
||||||
@ -155,7 +156,7 @@ const getSessionUser = function(req) {
|
|||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("Unauthorized (logged in) access by user: " + req.user.username);
|
console.log("Unauthorized (logged in) access by user: " + user.username);
|
||||||
user.restriction = "Unauthorized access attempt to restricted album.";
|
user.restriction = "Unauthorized access attempt to restricted album.";
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
@ -204,9 +205,9 @@ router.post("/login", function(req, res) {
|
|||||||
|
|
||||||
return ldapPromise(username, password).then(function(ldap) {
|
return ldapPromise(username, password).then(function(ldap) {
|
||||||
let user = {};
|
let user = {};
|
||||||
user.name = ldap.displayName;
|
|
||||||
user.username = ldap.uid;
|
|
||||||
user.id = "LDAP";
|
user.id = "LDAP";
|
||||||
|
user.displayName = ldap.displayName;
|
||||||
|
user.username = ldap.uid;
|
||||||
user.mail = ldap.mail;
|
user.mail = ldap.mail;
|
||||||
user.authenticated = 1;
|
user.authenticated = 1;
|
||||||
user.mailVerified = 1;
|
user.mailVerified = 1;
|
||||||
@ -252,6 +253,7 @@ router.post("/login", function(req, res) {
|
|||||||
return res.status(200).send(user);
|
return res.status(200).send(user);
|
||||||
});
|
});
|
||||||
}).catch(function(error) {
|
}).catch(function(error) {
|
||||||
|
console.log(error);
|
||||||
return res.status(403).send(error);
|
return res.status(403).send(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user