public function create_newuser() { $email = $this->request->get('value'); if (!\Swift_Validate::email($email)) { throw new \Exception_InvalidArgument('Invalid mail address'); } if (null === ($createdUser = $this->app['manipulator.user']->getRepository()->findByEmail($email))) { $sendCredentials = !!$this->request->get('send_credentials', false); $validateMail = !!$this->request->get('validate_mail', false); $createdUser = $this->app['manipulator.user']->createUser($email, \random::generatePassword(16), $email); $receiver = null; try { $receiver = Receiver::fromUser($createdUser); } catch (InvalidArgumentException $e) { } if ($sendCredentials) { $urlToken = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->getId()); if ($receiver && false !== $urlToken) { $url = $this->app->url('login_renew_password', ['token' => $urlToken]); $mail = MailRequestPasswordSetup::create($this->app, $receiver, null, '', $url); $mail->setLogin($createdUser->getLogin()); $this->app['notification.deliverer']->deliver($mail); } } if ($validateMail) { $createdUser->setMailLocked(true); if ($receiver) { $expire = new \DateTime('+3 days'); $token = $this->app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $createdUser->getId(), $expire, $createdUser->getEmail()); $url = $this->app->url('login_register_confirm', ['code' => $token]); $mail = MailRequestEmailConfirmation::create($this->app, $receiver, null, '', $url, $expire); $this->app['notification.deliverer']->deliver($mail); } } } $this->usr_id = $createdUser->getId(); return $createdUser; }
/** * Sends an account unlock email. * * @param PhraseaApplication $app * @param User $user * * @throws InvalidArgumentException * @throws RuntimeException */ private function sendAccountUnlockEmail(PhraseaApplication $app, User $user) { $receiver = Receiver::fromUser($user); $expire = new \DateTime('+3 days'); $token = $app['tokens']->getUrlToken(\random::TYPE_PASSWORD, $user->getId(), $expire, $user->getEmail()); $mail = MailRequestEmailConfirmation::create($app, $receiver); $mail->setButtonUrl($app->url('login_register_confirm', ['code' => $token])); $mail->setExpiration($expire); $app['notification.deliverer']->deliver($mail); }
public function create_newuser() { $email = $this->request->get('value'); if (!\Swift_Validate::email($email)) { throw new \Exception_InvalidArgument('Invalid mail address'); } if (null === ($createdUser = $this->app['repo.users']->findByEmail($email))) { $sendCredentials = !!$this->request->get('send_credentials', false); $validateMail = !!$this->request->get('validate_mail', false); $createdUser = $this->app['manipulator.user']->createUser($email, $this->app['random.medium']->generateString(128), $email); $receiver = null; try { $receiver = Receiver::fromUser($createdUser); } catch (InvalidArgumentException $e) { } if ($sendCredentials && $receiver) { $urlToken = $this->app['manipulator.token']->createResetPasswordToken($createdUser); $url = $this->app->url('login_renew_password', ['token' => $urlToken->getValue()]); $mail = MailRequestPasswordSetup::create($this->app, $receiver, null, '', $url); $mail->setLogin($createdUser->getLogin()); $this->app['notification.deliverer']->deliver($mail); } if ($validateMail && $receiver) { $createdUser->setMailLocked(true); $token = $this->app['manipulator.token']->createAccountUnlockToken($createdUser); $url = $this->app->url('login_register_confirm', ['code' => $token]); $mail = MailRequestEmailConfirmation::create($this->app, $receiver, null, '', $url, $token->getExpiration()); $this->app['notification.deliverer']->deliver($mail); } } $this->usr_id = $createdUser->getId(); return $createdUser; }
public function getMail() { return MailRequestEmailConfirmation::create($this->getApp(), $this->getReceiverMock(), $this->getEmitterMock(), $this->getMessage(), $this->getUrl(), $this->getExpiration()); }
/** * Sends an account unlock email. * * @param User $user */ private function sendAccountUnlockEmail(User $user) { $receiver = Receiver::fromUser($user); $token = $this->getTokenManipulator()->createAccountUnlockToken($user); $mail = MailRequestEmailConfirmation::create($this->app, $receiver); $mail->setButtonUrl($this->app->url('login_register_confirm', ['code' => $token->getValue()])); $mail->setExpiration($token->getExpiration()); $this->deliver($mail); }
/** * Sends an account unlock email. * * @param PhraseaApplication $app * @param User $user * * @throws InvalidArgumentException * @throws RuntimeException */ private function sendAccountUnlockEmail(PhraseaApplication $app, User $user) { $receiver = Receiver::fromUser($user); $token = $app['manipulator.token']->createAccountUnlockToken($user); $mail = MailRequestEmailConfirmation::create($app, $receiver); $mail->setButtonUrl($app->url('login_register_confirm', ['code' => $token->getValue()])); $mail->setExpiration($token->getExpiration()); $app['notification.deliverer']->deliver($mail); }