示例#1
0
 public function signIn()
 {
     if (!isset($_POST['signIn'])) {
         return;
     }
     $this->setFromPost();
     $fields = [];
     $fields['token'] = $this->validateToken();
     $fields['email'] = $this->validateEmail(false);
     $fields['password'] = $this->validatePassword();
     $this->getValidation()->setFields($fields);
     if ($this->getValidation()->isValid()) {
         $signedUser = Service::loadByEmail($this->getModel()->getEmail(), $this->getModel()->getPassword());
         if (Util\Auth::isAuth($signedUser)) {
             Util\Session::set('allSuccess', Util\Lang::lang('hi', [$signedUser->getUsername()]));
             Util\Session::set('signedUser', $signedUser->getId());
             if (!empty($_POST['persistentCookie'])) {
                 \Rebond\Core\UserSecurity\Service::saveSecure($signedUser, \Rebond\Core\UserSecurity\Model::REMEMBER);
             }
             Util\Log::log(Util\Error::USER_SIGNIN, $signedUser->getId(), __FILE__, __LINE__);
             $this->setModel($signedUser);
         } else {
             Util\Session::set('allError', Util\Lang::lang('incorrectEmailPassword'));
         }
     } else {
         Util\Session::set('allError', $this->getValidation()->getMessage());
     }
 }
示例#2
0
文件: Mail.php 项目: vincium/resa
 public static function resetPassword($siteTitle, \Rebond\Core\User\Model $user)
 {
     $userSecure = \Rebond\Core\UserSecurity\Service::saveSecure($user->getId(), \Rebond\Core\UserSecurity\Model::RESET);
     $tpl = new Util\Template(Util\Template::SITE, ['mail']);
     $tpl->set('url', \Rebond\Config::getPath('siteUrl'));
     $tpl->set('site', $siteTitle);
     $tpl->set('item', $user);
     $tpl->set('reset', $userSecure->getSecure());
     $tplMail = new Util\Template(Util\Template::SITE, ['mail']);
     $tplMail->set('title', Util\Lang::lang('resetPassword'));
     $tplMail->set('site', $siteTitle);
     $tplMail->set('url', \Rebond\Config::getPath('siteUrl'));
     $tplMail->set('layout', $tpl->render('reset-password'));
     $message = \Swift_Message::newInstance()->setContentType('text/html')->setSubject($siteTitle . ' - ' . Util\Lang::lang('resetPassword'))->setFrom(\Rebond\Config::getMail('email'))->setTo($user->getEmail())->setBody($tplMail->render('tpl-default'));
     return Util\Mail::send($message);
 }