/** * @param Request $request * @param TokenInterface $token * * @return RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function onAuthenticationSuccess(Request $request, TokenInterface $token) { $token->getUser()->setLastlogin(new \DateTime()); $token->getUser()->save(); $log = new UserLog(); $log->setIpSource($request->getClientIp()); $token->getUser()->addUserLog($log); $token->getUser()->save(); /** @var SecurityContext $securityContext */ $securityContext = $this->container->get('security.context'); if ($securityContext->isGranted('ROLE_SUPER_ADMIN')) { return new RedirectResponse($this->container->get('router')->generate('sonata_admin_dashboard')); } if ($securityContext->isGranted('ROLE_ADMIN')) { return new RedirectResponse($this->container->get('router')->generate('pgs_admin_dashboard')); } if ($securityContext->isGranted('ROLE_OFFICE')) { return new RedirectResponse($this->container->get('router')->generate('pgs_office_dashboard')); } if ($securityContext->isGranted('ROLE_PRINCIPAL')) { return new RedirectResponse($this->container->get('router')->generate('pgs_principal_dashboard')); } if ($securityContext->isGranted('ROLE_SALES')) { return new RedirectResponse($this->container->get('router')->generate('pgs_sales_dashboard')); } if ($securityContext->isGranted('ROLE_USER')) { return new RedirectResponse($this->container->get('router')->generate('homepage')); } }
/** * @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(); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param UserLog $obj A UserLog object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null UserLogPeer::$instances[$key] = $obj; } }
/** * Filter the query by a related UserLog object * * @param UserLog|PropelObjectCollection $userLog the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return UserQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByUserLog($userLog, $comparison = null) { if ($userLog instanceof UserLog) { return $this->addUsingAlias(UserPeer::ID, $userLog->getUserId(), $comparison); } elseif ($userLog instanceof PropelObjectCollection) { return $this->useUserLogQuery()->filterByPrimaryKeys($userLog->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByUserLog() only accepts arguments of type UserLog or PropelCollection'); } }
/** * @param UserLog $userLog The userLog object to add. */ protected function doAddUserLog($userLog) { $this->collUserLogs[] = $userLog; $userLog->setUser($this); }
/** * Exclude object from result * * @param UserLog $userLog Object to remove from the list of results * * @return UserLogQuery The current query, for fluid interface */ public function prune($userLog = null) { if ($userLog) { $this->addUsingAlias(UserLogPeer::ID, $userLog->getId(), Criteria::NOT_EQUAL); } return $this; }