public function cleancookiesAction() { if (!empty($_COOKIE)) { $sessionDomain = $this->getDI()->getConfig()->session->cookie_params->domain; foreach ($_COOKIE as $key => $cookie) { $this->cookies->get($key)->setDomain($sessionDomain)->delete(); } } return $this->response->redirect(eva_url('passport', '/login')); }
public function indexAction() { $next = eva_url('wscnAdmin', '/admin/dashboard'); if ($this->request->getHTTPReferer()) { $next = $this->request->getHTTPReferer(); } return $this->response->redirect(eva_url('passport', '/login', ['next' => $next])); $this->view->changeRender('admin/login/index'); $this->dispatcher->setParam('loginSuccessRedirectUri', '/admin/dashboard'); $this->dispatcher->forward(array('namespace' => 'Eva\\EvaUser\\Controllers', 'controller' => 'login', 'action' => 'index')); }
public function sendPasswordResetMail($email, $forceSend = false) { if (false === $forceSend && $this->getDI()->getConfig()->mailer->async) { $queue = $this->getDI()->get('queue'); $result = $queue->doBackground('sendmailAsync', json_encode(array('class' => __CLASS__, 'method' => __FUNCTION__, 'parameters' => array($email, true)))); return true; } $userinfo = self::findFirst("email= '{$email}'"); if (!$userinfo) { throw new Exception\ResourceNotFoundException('ERR_USER_NOT_EXIST'); } $mailer = $this->getDI()->get('mailer'); $message = $this->getDI()->get('mailMessage'); $message->setTo(array($userinfo->email => $userinfo->username)); $message->setTemplate($this->getDI()->getConfig()->user->resetMailTemplate); $message->assign(array('user' => $userinfo->toArray(), 'url' => eva_url('passport', '/session/reset/' . urlencode($userinfo->username) . '/' . $userinfo->passwordResetHash))); return $mailer->send($message->getMessage()); }
public function sendChangeEmailVerificationEmail($username, $newEmail, $forceSend = false) { if (false === $forceSend && $this->getDI()->getConfig()->mailer->async) { $queue = $this->getDI()->getQueue(); $result = $queue->doBackground('sendmailAsync', json_encode(array('class' => __CLASS__, 'method' => __FUNCTION__, 'parameters' => array($username, $newEmail, true)))); return true; } $user = self::findFirst("username = '******'"); if (!$user) { throw new Exception\ResourceNotFoundException('ERR_USER_NOT_EXIST'); } $mailer = $this->getDI()->getMailer(); $message = $this->getDI()->getMailMessage(); $message->setTo(array($newEmail => $user->username)); //Change email hash will expired when password / email changed $verifyCode = md5($user->id . $user->password . $user->email . $newEmail); $message->setTemplate($this->getDI()->getConfig()->user->changeEmailTemplate); $message->assign(array('user' => $user->toArray(), 'url' => eva_url('passport', '/session/changemail/' . urlencode($user->username) . '/' . urlencode($newEmail) . '/' . $verifyCode))); $mailer->send($message->getMessage()); }
public function sendVerificationEmail($identify, $forceSend = false) { if (false === $forceSend && $this->getDI()->getConfig()->mailer->async) { $queue = $this->getDI()->getQueue(); $result = $queue->doBackground('sendmailAsync', json_encode(array('class' => __CLASS__, 'method' => __FUNCTION__, 'parameters' => array($identify, true)))); return true; } $userinfo = array(); if (false === strpos($identify, '@')) { $userinfo = self::findFirst("username = '******'"); } else { $userinfo = self::findFirst("email = '{$identify}'"); } if (!$userinfo) { throw new Exception\ResourceNotFoundException('ERR_USER_NOT_EXIST'); } if (!$userinfo->activationHash) { $userinfo->activationHash = sha1(uniqid(mt_rand(), true)); $userinfo->save(); } $mailer = $this->getDI()->getMailer(); $message = $this->getDI()->getMailMessage(); $message->setTo(array($userinfo->email => $userinfo->username)); $template = self::getVerificationEmailTemplate(); $template = $template ?: $this->getDI()->getConfig()->user->activeMailTemplate; $message->setTemplate($template); $message->assign(array('user' => $userinfo->toArray(), 'url' => eva_url('passport', '/session/verify/' . urlencode($userinfo->username) . '/' . $userinfo->activationHash))); $mailer->send($message->getMessage()); return true; }