public function checkPostAuth(UserInterface $user)
 {
     if (!$user instanceof AdvancedUserInterface) {
         return;
     }
     if (!$user->isAccountNonLocked()) {
         $ex = new LockedException('User account is locked.');
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isEnabled() and $user->getStatus() == User::STATUS_BAD_EMAIL) {
         $ex = new DisabledException('BAD_EMAIL');
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isEnabled()) {
         $ex = new DisabledException('DISABLED');
         if ($user instanceof User && $user->getConfirmationToken()) {
             $ex = new DisabledException('DISABLED:' . Strings::base64EncodeUrl($user->getEmail()));
         }
         $ex->setUser($user);
         throw $ex;
     }
     if (!$user->isAccountNonExpired()) {
         $ex = new AccountExpiredException('User account has expired.');
         $ex->setUser($user);
         throw $ex;
     }
 }
 public function slugify($string)
 {
     return Strings::slugify($string);
 }
 /**
  *
  * @Route("/unsubscribe/{type}/{email}", name="user_unsubscribe")
  * @Template
  */
 public function unsubscribeAction($type, $email)
 {
     $notifType = $this->repo('NotificationType')->find($type);
     if (!$notifType) {
         throw $this->createNotFoundException('Unknown notification type');
     }
     $email = Strings::base64DecodeUrl($email);
     /** @var UserManager $userMgr */
     $userMgr = $this->get('fos_user.user_manager');
     /** @var User $user */
     $user = $userMgr->findUserByEmail($email);
     if (!$user) {
         throw $this->createNotFoundException('Unknown user');
     }
     $sub = NotificationSub::make($user, $notifType);
     if ($oldsub = $user->hasNotificationSub($sub)) {
         $user->removeNotificationSub($oldsub);
         $this->em()->remove($oldsub);
         $this->em()->flush();
     }
     return ['newsletter' => $notifType];
 }
 /**
  * @Route("/register/resend/{email}", name="register_resend")
  */
 public function resendConfirmationAction($email)
 {
     $email = Strings::base64DecodeUrl($email);
     $user = $this->get('fos_user.user_manager')->findUserByEmail($email);
     if ($user === null) {
         throw new NotFoundHttpException(sprintf('The user with email "%s" does not exist', htmlentities($email)));
     }
     $token = $user->getConfirmationToken();
     if (empty($token)) {
         $user->setConfirmationToken($this->get('fos_user.util.token_generator')->generateToken());
         $this->get('fos_user.user_manager')->updateUser($user);
     }
     $this->sendConfirmationEmailMessage($user, null);
     $this->flash('success', 'The confirmation email was re-sent to ' . htmlentities($email));
     $this->get('session')->save();
     return $this->redirectRoute('fos_user_security_login');
     //, ['resent_confirmation' => 1]);
 }
Example #5
0
 public function generateUnsubscribeLink(NotificationType $type, RouterInterface $urlGen)
 {
     $email = Strings::base64EncodeUrl($this->getEmail());
     return $urlGen->generate('user_unsubscribe', ['type' => $type->getId(), 'email' => $email], UrlGeneratorInterface::ABSOLUTE_URL);
 }
Example #6
0
 private function getUnsubscribeLink(MassMailQueue $entry, array $user)
 {
     $filter = $entry->getFilterSpec();
     if (isset($filter['notificationTypeId'])) {
         return $this->router->generate('user_unsubscribe', ['type' => $filter['notificationTypeId'], 'email' => Strings::base64EncodeUrl($user['email'])], true);
     }
     return false;
 }