/** * This is called when an interactive authentication attempt succeeds. This * is called by authentication listeners inheriting from * AbstractAuthenticationListener. * * @param AuthenticationEvent $event Event triggering this callback. * * @return void */ public function onAuthenticationSuccess(AuthenticationEvent $event) { /** @var \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token */ $token = $event->getAuthenticationToken(); $contractNumber = '?'; $tokenUser = $token->getUser(); if ($tokenUser instanceof SecurityContract) { $contractNumber = $tokenUser->getContractNumber(); } $this->logger->info(sprintf('Entity (%s (%s)) was successfully recognized.', $token->getUsername(), $contractNumber)); }
/** * @param AuthenticationEvent $event */ public function onAuthenticationSuccess(AuthenticationEvent $event) { /** @var User $user */ $user = $this->userManager->findOneById($event->getAuthenticationToken()->getUser()->getId()); // logging $userLog = new UserLog(); $userLog->setUser($user)->setIpSource($this->request->getCurrentRequest()->getClientIp())->save(); }
public function onAuthenticationSuccess(AuthenticationEvent $event) { $token = $event->getAuthenticationToken(); /* @var $user User */ $user = $this->container->get('logic')->getUserByName($token->getUsername()); if ($user) { $user->setAttempts(0); $this->em->flush(); } }
/** * @param AuthenticationEvent $event Authentication success event */ public function onAuthenticationSuccess(AuthenticationEvent $event) { $user = $event->getAuthenticationToken()->getUser(); if (is_a($user, 'Bangpound\\Bundle\\DrupalBundle\\Security\\User\\User')) { /** @var \Bangpound\Bundle\DrupalBundle\Security\User\User $user */ $GLOBALS['user'] = $user->getDrupalUser(); $edit = $this->requestStack->getCurrentRequest()->request->all(); user_login_finalize($edit); } }
/** * @param AuthenticationEvent $event */ public function onAuthenticationSuccess(AuthenticationEvent $event) { $token = $event->getAuthenticationToken(); $user = $token->getUser(); /** @var ClientInterface $user */ if ($user instanceof ClientInterface) { $accessToken = hash('sha256', uniqid(microtime(true))); $user->setAccessToken($accessToken); $this->clientProvider->updateClient($user); } }
public function onUserLogin(AuthenticationEvent $event) { // No anonymous user $roles = $event->getAuthenticationToken()->getRoles(); $anonymous = true; foreach ($roles as $role) { if ($role->getRole() === "ROLE_USER") { $anonymous = false; break; } } if (!$anonymous) { $user = $event->getAuthenticationToken()->getUser(); $home = $user->getHome(); // set project as current project in session if ($home) { $this->session->set('projectid', $home->getId()); } } }
/** * Assign the Cart stored in session to the logged Customer. * * When a user has successfully logged in, a check is needed * to see if a Cart was created in session when she was not * logged. * * @param AuthenticationEvent $event Event */ public function onAuthenticationSuccess(AuthenticationEvent $event) { $loggedUser = $event->getAuthenticationToken()->getUser(); $cart = $this->cartWrapper->get(); if ($loggedUser instanceof CustomerInterface && ($cart instanceof CartInterface && $cart->getId())) { /* * We assume that a cart with an ID is * not a pristine entity coming from a * factory method. (i.e. has already been * flushed) */ $cart->setCustomer($loggedUser); $this->cartManager->flush($cart); } }
public function onAuthenticationSuccess(AuthenticationEvent $event) { $token = $event->getAuthenticationToken(); if (!$token) { return; } $user = $token->getUser(); if (!$user instanceof User) { return; } $user->recordUserAgent($this->request->headers->get('User-Agent')); $user->recordLastLogin($this->request->getClientIp()); $this->entityManager->persist($user); $this->entityManager->flush(); }
public function onAuthenticationSuccess(AuthenticationEvent $event) { $token = $event->getAuthenticationToken(); $user = $token->getUser(); if ($user instanceof User) { $this->session->set(CustomerRepository::CUSTOMER_ID, $user->getId()); if (!is_null($user->getCartItemCount())) { $this->session->set(CartRepository::CART_ITEM_COUNT, $user->getCartItemCount()); } else { $this->session->remove(CartRepository::CART_ITEM_COUNT); } if (!is_null($user->getCartId())) { $this->session->set(CartRepository::CART_ID, $user->getCartId()); } else { $this->session->remove(CartRepository::CART_ID); $this->session->remove(CartRepository::CART_ITEM_COUNT); } } }
public function onKernelLogOk(AuthenticationEvent $event) { $ip = $_SERVER['REMOTE_ADDR']; $useragent = $_SERVER['HTTP_USER_AGENT']; $token = $event->getAuthenticationToken(); $user = $token->getUser(); $session = new Session(); if (gettype($user) != 'string') { $log = new Log(); $log->setUser($user); $log->setIp($ip); $log->setEtat(true); $log->setUseragent($useragent); $this->em->persist($log); $user->setLogged(true); $user->setTimeUpdate(new \DateTime()); $user->setLogIn($log); $this->em->flush(); $session->set('log', $log->getId()); } }
/** * @param AuthenticationEvent $event */ public function onSuccess(AuthenticationEvent $event) { $this->logger->debug('SUCCESS : ' . $event->getAuthenticationToken()->getUsername()); }
public function onAuthenticationSuccess(AuthenticationEvent $event) { $user = $event->getAuthenticationToken()->getUser(); $this->discriminate($user); }
/** * @param AuthenticationEvent $event */ public function onLoginSuccess(AuthenticationEvent $event) { $user = $event->getAuthenticationToken()->getUser(); }