mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 09:36:44 +00:00
refactor(core): Decouple LDAP from internal hooks (no-changelog) (#10157)
Co-authored-by: Ricardo Espinoza <ricardo@n8n.io>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { User } from '@db/entities/User';
|
||||
import { PasswordUtility } from '@/services/password.utility';
|
||||
import { Container } from 'typedi';
|
||||
import { InternalHooks } from '@/InternalHooks';
|
||||
import { isLdapLoginEnabled } from '@/Ldap/helpers.ee';
|
||||
import { UserRepository } from '@db/repositories/user.repository';
|
||||
import { AuthError } from '@/errors/response-errors/auth.error';
|
||||
import { EventService } from '@/eventbus/event.service';
|
||||
|
||||
export const handleEmailLogin = async (
|
||||
email: string,
|
||||
@@ -23,9 +23,7 @@ export const handleEmailLogin = async (
|
||||
// so suggest to reset the password to gain access to the instance.
|
||||
const ldapIdentity = user?.authIdentities?.find((i) => i.providerType === 'ldap');
|
||||
if (user && ldapIdentity && !isLdapLoginEnabled()) {
|
||||
void Container.get(InternalHooks).userLoginFailedDueToLdapDisabled({
|
||||
user_id: user.id,
|
||||
});
|
||||
Container.get(EventService).emit('login-failed-due-to-ldap-disabled', { userId: user.id });
|
||||
|
||||
throw new AuthError('Reset your password to gain access to the instance.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user