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()); } }
public function sign_in() { // auth if (Auth::isAdminAuthorized($this->signedUser)) { Session::redirect('/'); } // action $form = new \Rebond\Core\User\Form($this->signedUser); $form->signIn(); if (Auth::isAdmin($form->getModel())) { Session::redirect('/'); } if (Auth::isAuth($form->getModel())) { Session::setAndRedirect('siteError', Lang::lang('accessNonAuthorized'), 'http://' . \Rebond\Config::getPath('siteUrl')); } // view $this->setTpl(); // main $tplMain = new Template(Template::MODULE, ['core', 'user']); $tplMain->set('item', $form); // master $this->tplMaster->set('column1', $tplMain->render('sign-in')); $this->tplMaster->set('jsLauncher', 'profile'); return $this->tplMaster->render('tpl-signin'); }
public function changePassword() { $signedUser = $this->app->user(); // auth if (!Util\Auth::isAuth($signedUser)) { header('Location: /profile'); exit; } $form = new \Rebond\Core\User\Form($signedUser); // action $change = Util\Converter::toString('resetPassword', 'post'); if (isset($change)) { $form->changePassword('/profile'); } $tpl = new Util\Template(Util\Template::MODULE, ['app', 'User']); $tpl->set('item', $form); $tpl->set('checkCurrentPassword', true); return $tpl->render('password-change'); }