fix(core): Fix issue that prevents owner logging in when using ldap (#7408)

This PR prioritises the internal email account over LDAP for the Owner.

---------

Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
Jon
2023-11-02 03:02:49 +00:00
committed by GitHub
parent 437c95e84e
commit 479f90231d
4 changed files with 45 additions and 6 deletions

View File

@@ -4,6 +4,7 @@ import { compareHash } from '@/UserManagement/UserManagementHelper';
import * as ResponseHelper from '@/ResponseHelper';
import { Container } from 'typedi';
import { InternalHooks } from '@/InternalHooks';
import { isLdapLoginEnabled } from '@/Ldap/helpers';
export const handleEmailLogin = async (
email: string,
@@ -21,7 +22,7 @@ export const handleEmailLogin = async (
// At this point if the user has a LDAP ID, means it was previously an LDAP user,
// so suggest to reset the password to gain access to the instance.
const ldapIdentity = user?.authIdentities?.find((i) => i.providerType === 'ldap');
if (user && ldapIdentity) {
if (user && ldapIdentity && !isLdapLoginEnabled()) {
void Container.get(InternalHooks).userLoginFailedDueToLdapDisabled({
user_id: user.id,
});