mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 18:30:13 +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;
|
let ldapUser;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ldap.connectSync();
|
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);
|
const users = ldap.searchUsersSync(loginRequest.username);
|
||||||
|
|
||||||
if (users.length !== 1) {
|
if (users.length !== 1) {
|
||||||
|
|
@ -58,11 +65,14 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
|
||||||
} else {
|
} else {
|
||||||
log_info('Wrong password for', loginRequest.username);
|
log_info('Wrong password for', loginRequest.username);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log_error(error);
|
log_error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ldapUser === undefined) {
|
if (!ldapUser) {
|
||||||
if (LDAP.settings_get('LDAP_LOGIN_FALLBACK') === true) {
|
if (LDAP.settings_get('LDAP_LOGIN_FALLBACK') === true) {
|
||||||
return fallbackDefaultAccountSystem(self, loginRequest.username, loginRequest.ldapPass);
|
return fallbackDefaultAccountSystem(self, loginRequest.username, loginRequest.ldapPass);
|
||||||
}
|
}
|
||||||
|
|
@ -76,7 +86,6 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
|
||||||
|
|
||||||
const Unique_Identifier_Field = getLdapUserUniqueID(ldapUser);
|
const Unique_Identifier_Field = getLdapUserUniqueID(ldapUser);
|
||||||
let user;
|
let user;
|
||||||
|
|
||||||
// Attempt to find user by unique identifier
|
// Attempt to find user by unique identifier
|
||||||
|
|
||||||
if (Unique_Identifier_Field) {
|
if (Unique_Identifier_Field) {
|
||||||
|
|
@ -105,6 +114,7 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
|
||||||
email = getLdapEmail(ldapUser);
|
email = getLdapEmail(ldapUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
if(email && LDAP.settings_get('LDAP_EMAIL_MATCH_REQUIRE') === true) {
|
if(email && LDAP.settings_get('LDAP_EMAIL_MATCH_REQUIRE') === true) {
|
||||||
if(LDAP.settings_get('LDAP_EMAIL_MATCH_VERIFIED') === true) {
|
if(LDAP.settings_get('LDAP_EMAIL_MATCH_VERIFIED') === true) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue