Пример #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
 public function status()
 {
     $signedUser = $this->app->user();
     if (isset($_POST['sign-out'])) {
         \Rebond\Core\UserSecurity\Service::signOut($signedUser);
     }
     $tpl = new Util\Template(Util\Template::MODULE, ['app', 'User']);
     if (Util\Auth::isAuth($signedUser)) {
         $tpl->set('email', $signedUser->getEmail());
     }
     return $tpl->render('status');
 }
Пример #3
0
 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);
 }
Пример #4
0
 public function index()
 {
     if (isset($_POST['sign-out'])) {
         \Rebond\Core\UserSecurity\Service::signOut($this->signedUser);
     }
     // main
     $tplMain = new Util\Template(Util\Template::SITE, ['www']);
     if ($this->player->getId() == 0) {
         $tpl = 'index-guest';
         $matchView = \Own\Bus\Match\Data::loadLastMatch();
     } else {
         $tpl = 'index';
         $matchView = \Own\Bus\Match\Data::loadRecentByPlayerId($this->player->getId());
         $nextMatch = \Own\Bus\Match\Data::loadNextMatchByPlayerId($this->player->getId());
         $soon = isset($nextMatch) && $nextMatch->getScheduled() < time() + Engine::DAY * 360 ? true : false;
         $tplMain->set('player', $this->player);
         $tplMain->set('notificationCount', \Own\Bus\Notification\Data::countByPlayerId($this->player->getId()));
         $tplMain->set('isBonusDayXp', $this->player->isBonusDayXp());
         $tplMain->set('nextBonusDayXp', $this->player->getNextBonusDayXp());
         $tplMain->set('nextMatch', $nextMatch);
         $tplMain->set('soon', $soon);
     }
     $tplMain->set('matchView', $matchView);
     $options = [];
     $options['where'][] = 'configuration.property = \'nextWeek\'';
     $nextWeek = \Own\Bus\Configuration\Data::load($options);
     $options = [];
     $options['where'][] = 'configuration.property = \'nextMonth\'';
     $nextMonth = \Own\Bus\Configuration\Data::load($options);
     $options = [];
     $options['where'][] = 'configuration.property = \'nextYear\'';
     $nextYear = \Own\Bus\Configuration\Data::load($options);
     if (!isset($nextWeek, $nextMonth, $nextYear)) {
         Util\error::kill(Util\Code::UNHANDLED_ERROR, 'nextWeek, nextMonth or nextYear is not set in bus_configuration', __FILE__, __LINE__);
     }
     $tplMain->set('gameTime', Engine::renderTime($this->app->site()->getCreatedDate()));
     $tplMain->set('endWeek', (new Util\DateTime())->setTimestamp($nextWeek->getValue()));
     $tplMain->set('endMonth', (new Util\DateTime())->setTimestamp($nextMonth->getValue()));
     $tplMain->set('endYear', (new Util\DateTime())->setTimestamp($nextYear->getValue()));
     // view
     $this->setTpl();
     // layout
     $this->tplLayout->set('column1', $tplMain->render($tpl));
     // template
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-center'));
     return $this->tplMaster->render('tpl-default');
 }
Пример #5
0
 public function index()
 {
     // auth
     Util\Auth::isAuthorized($this->signedUser, 'member', false, '/profile/sign-in');
     if (isset($_POST['sign-out'])) {
         \Rebond\Core\UserSecurity\Service::signOut($this->signedUser);
     }
     // view
     $this->setTpl();
     // main
     $tplMain = new Util\Template(Util\Template::SITE, ['www']);
     // layout
     $this->tplLayout->set('column1', $tplMain->render('index'));
     // template
     $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col'));
     return $this->tplMaster->render('tpl-default');
 }
Пример #6
0
 public function sign_out()
 {
     \Rebond\Core\UserSecurity\Service::signOut($this->signedUser);
 }
Пример #7
0
 public function forgotPassword()
 {
     $signedUser = $this->app->user();
     // auth
     if (Util\Auth::isAuth($signedUser)) {
         header('Location: /profile');
         exit;
     }
     $form = new \Rebond\Core\User\Form($signedUser);
     $tpl = new Util\Template(Util\Template::MODULE, ['app', 'User']);
     // action
     // request
     $requestForgotPassword = Util\Converter::toString('requestForgotPassword', 'post');
     if (isset($requestForgotPassword)) {
         $email = Util\Converter::toString('email', 'post');
         if ($email == '') {
             Util\Session::set(Util\Lang::lang('siteError', 'emptyEmailAddress'));
         } else {
             $user = \Rebond\Core\User\Data::loadByEmail($email);
             if (isset($user)) {
                 Util\Mail::resetPassword($this->app->site()->getTitle(), $user);
                 return $tpl->render('forgot-password-send');
             } else {
                 Util\Session::set('siteError', Util\Lang::lang('emailAddressNotFound'));
             }
         }
     }
     // reset password form
     $reset = Util\Converter::toString('reset');
     if (isset($reset)) {
         $user = \Rebond\Core\UserSecurity\Service::getUserBySecure($reset, \Rebond\Core\UserSecurity\Model::RESET);
         if (isset($user)) {
             $form = new \Rebond\Core\User\Form($user);
             // reset password
             $resetPassword = Util\Converter::toString('resetPassword', 'post');
             if (isset($resetPassword)) {
                 $form->changePassword('/profile', false);
             }
             $tpl = new Util\Template(Util\Template::MODULE, ['app', 'User']);
             $tpl->set('item', $form);
             $tpl->set('checkCurrentPassword', false);
             return $tpl->render('password-change');
         }
     }
     $tpl = new Util\Template(Util\Template::MODULE, ['app', 'User']);
     $tpl->set('item', $form);
     return $tpl->render('forgot-password');
 }