Code Duplication    Length = 9-10 lines in 2 locations

Security/Authentication/Provider/LdapAuthenticationProvider.php 1 location

@@ 134-142 (lines=9) @@
131
        /** @var AuthenticationResponse $response */
132
        $response = $this->ldap->getConnection()->execute($auth);
133
134
        if (!$response->isAuthenticated()) {
135
            $this->userChecker->checkLdapErrorCode(
136
                $user,
137
                $response->getErrorCode(),
138
                $this->ldap->getConnection()->getConfig()->getLdapType()
139
            );
140
141
            throw new BadCredentialsException($response->getErrorMessage(), $response->getErrorCode());
142
        }
143
        $this->dispatcher->dispatch(LdapLoginEvent::SUCCESS, new LdapLoginEvent($user, $token));
144
145
        $newToken = new UsernamePasswordToken($user, null, $this->providerKey, $user->getRoles());

Security/LdapGuardAuthenticator.php 1 location

@@ 171-180 (lines=10) @@
168
            $response = $this->ldap->getConnection()->execute(
169
                new AuthenticationOperation($user->getUsername(), $credentials['password'])
170
            );
171
            if (!$response->isAuthenticated()) {
172
                $this->userChecker->checkLdapErrorCode(
173
                    $user,
174
                    $response->getErrorCode(),
175
                    $this->ldap->getConnection()->getConfig()->getLdapType()
176
                );
177
                throw new CustomUserMessageAuthenticationException(
178
                    $response->getErrorMessage(), [], $response->getErrorCode()
179
                );
180
            }
181
            // No way to get the token from the Guard, need to create one to pass...
182
            $token = new UsernamePasswordToken($user, $credentials['password'], 'ldap-tools', $user->getRoles());
183
            $token->setAttribute('ldap_domain', isset($credentials['ldap_domain']) ? $credentials['ldap_domain'] : '');