/**
  * {@inheritdoc}
  */
 public function checkAuthentication(UserInterface $user, UsernamePasswordToken $token)
 {
     $connector = new \EpitechAPI\Connector();
     try {
         $connector->authenticate(\EpitechAPI\Connector::SIGN_IN_METHOD_CREDENTIALS, $user->getUsername(), $token->getCredentials());
     } catch (\Exception $ex) {
         throw new \Exception("The Epitech's Intranet is not responding");
     }
     if (!$connector->isSignedIn()) {
         throw new BadCredentialsException();
     }
     $user->updateFromIntranet($connector->getUser());
     $user->setLastConnectionDate(new \DateTime());
     $roles = $user->getRoles();
     foreach (array_keys($roles, 'ROLE_SUPER_ADMIN') as $key) {
         unset($roles[$key]);
     }
     if (in_array($user->getLogin(), $this->superAdminsLogin)) {
         $roles[] = 'ROLE_SUPER_ADMIN';
     }
     $user->setRoles($roles);
     $this->entityManager->persist($user);
     $this->entityManager->flush();
 }