mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 10:20:14 +01:00
Update loginHandler.js
additional option to login in ldap server with user account
This commit is contained in:
parent
fd1af07e43
commit
36f148a7cb
1 changed files with 31 additions and 21 deletions
|
|
@ -41,7 +41,14 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
|
|||
let ldapUser;
|
||||
|
||||
try {
|
||||
|
||||
ldap.connectSync();
|
||||
|
||||
if (!!LDAP.settings_get('LDAP_USER_AUTHENTICATION')) {
|
||||
ldap.bindUserIfNecessary(loginRequest.username, loginRequest.ldapPass);
|
||||
ldapUser = ldap.searchUsersSync(loginRequest.username)[0];
|
||||
} else {
|
||||
|
||||
const users = ldap.searchUsersSync(loginRequest.username);
|
||||
|
||||
if (users.length !== 1) {
|
||||
|
|
@ -58,11 +65,14 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
|
|||
} else {
|
||||
log_info('Wrong password for', loginRequest.username);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
log_error(error);
|
||||
}
|
||||
|
||||
if (ldapUser === undefined) {
|
||||
if (!ldapUser) {
|
||||
if (LDAP.settings_get('LDAP_LOGIN_FALLBACK') === true) {
|
||||
return fallbackDefaultAccountSystem(self, loginRequest.username, loginRequest.ldapPass);
|
||||
}
|
||||
|
|
@ -76,7 +86,6 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
|
|||
|
||||
const Unique_Identifier_Field = getLdapUserUniqueID(ldapUser);
|
||||
let user;
|
||||
|
||||
// Attempt to find user by unique identifier
|
||||
|
||||
if (Unique_Identifier_Field) {
|
||||
|
|
@ -105,6 +114,7 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
|
|||
email = getLdapEmail(ldapUser);
|
||||
}
|
||||
|
||||
|
||||
if (!user) {
|
||||
if(email && LDAP.settings_get('LDAP_EMAIL_MATCH_REQUIRE') === true) {
|
||||
if(LDAP.settings_get('LDAP_EMAIL_MATCH_VERIFIED') === true) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue