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

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