Exemplo n.º 1
0
 /**
  * @param AdvancedUserInterface $user
  * @param $area
  */
 public function login(AdvancedUserInterface $user, $area)
 {
     $request = $this->container->get('request');
     // $area is the name of the firewall in your security.yml
     $token = new UsernamePasswordToken($user, $user->getPassword(), $area, $user->getRoles());
     $this->container->get("security.token_storage")->setToken($token);
     // Fire the login event
     // Logging the user in above the way we do it doesn't do this automatically
     $event = new InteractiveLoginEvent($request, $token);
     $this->container->get("event_dispatcher")->dispatch('security.interactive_login', $event);
 }
Exemplo n.º 2
0
 public function isEqualTo(AdvancedUserInterface $user)
 {
     if (!$user instanceof AdvancedUserInterface) {
         return false;
     }
     if ($this->password !== $user->getPassword()) {
         return false;
     }
     if ($this->getSalt() !== $user->getSalt()) {
         return false;
     }
     if ($this->username !== $user->getUsername()) {
         return false;
     }
     return true;
 }