/**
  * {@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();
 }
Example #2
0
 /**
  * Método requerido por la interfaz UserInterface
  */
 function equals(\Symfony\Component\Security\Core\User\UserInterface $usuario)
 {
     return $this->getLogin() == $usuario->getLogin();
 }
Example #3
0
 public function equals(UserInterface $user)
 {
     if ($user->getLogin() == $this->getLogin()) {
         return true;
     } else {
         return false;
     }
 }
Example #4
0
 public function equals(UserInterface $user)
 {
     return $user->getLogin() == $this->getLogin();
 }
Example #5
0
 /**
  * Devuelve si el usuario pasado es igual al actual
  * @param UserInterface $usuario
  * @return boolean
  */
 public function equals(UserInterface $usuario)
 {
     return $this->getLogin() == $usuario->getLogin();
 }