Code Duplication    Length = 9-10 lines in 2 locations

Security/Authentication/Provider/LdapAuthenticationProvider.php 1 location

@@ 150-158 (lines=9) @@
147
        /** @var AuthenticationResponse $response */
148
        $response = $this->ldap->getConnection()->execute($auth);
149
150
        if (!$response->isAuthenticated()) {
151
            $this->userChecker->checkLdapErrorCode(
152
                $user,
153
                $response->getErrorCode(),
154
                $this->ldap->getConnection()->getConfig()->getLdapType()
155
            );
156
157
            throw new BadCredentialsException($response->getErrorMessage(), $response->getErrorCode());
158
        }
159
        $this->dispatcher->dispatch(LdapLoginEvent::SUCCESS, new LdapLoginEvent($user, $token));
160
161
        $newToken = new UsernamePasswordToken($user, null, $this->providerKey, $user->getRoles());

Security/LdapGuardAuthenticator.php 1 location

@@ 200-209 (lines=10) @@
197
                    $credentials['password']
198
                )
199
            );
200
            if (!$response->isAuthenticated()) {
201
                $this->userChecker->checkLdapErrorCode(
202
                    $user,
203
                    $response->getErrorCode(),
204
                    $this->ldap->getConnection()->getConfig()->getLdapType()
205
                );
206
                throw new CustomUserMessageAuthenticationException(
207
                    $response->getErrorMessage(), [], $response->getErrorCode()
208
                );
209
            }
210
            // No way to get the token from the Guard, need to create one to pass...
211
            $token = new UsernamePasswordToken($user, $credentials['password'], 'ldap-tools', $user->getRoles());
212
            $token->setAttribute('ldap_domain', $credDomain);