Exemple #1
0
 /**
  * checkAccess
  *
  * @return  void
  *
  * @throws  RouteNotFoundException
  * @throws  \Exception
  */
 protected function checkAccess()
 {
     // Add your access checking
     if (!UserHelper::authorise()) {
         UserHelper::goToLogin($this->app->uri->full);
     }
 }
Exemple #2
0
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     if (!UserHelper::isLogin()) {
         UserHelper::goToLogin();
     }
     parent::prepareExecute();
 }
Exemple #3
0
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     if (!UserHelper::isLogin()) {
         UserHelper::goToLogin($this->app->uri->full);
     }
     parent::prepareExecute();
 }
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     if (UserHelper::isLogin()) {
         $this->redirect($this->getSuccessRedirect());
         return;
     }
     parent::prepareExecute();
 }
Exemple #5
0
 /**
  * register
  *
  * @param DataInterface|UserDataTrait $user
  *
  * @return  bool
  *
  * @throws \Exception
  */
 public function register(DataInterface $user)
 {
     if ($user->password) {
         $user->password = UserHelper::hashPassword($user->password);
     }
     $this->prepareDefaultData($user);
     $user->id = User::save($user)->id;
     return true;
 }
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     if (UserHelper::isLogin()) {
         $warder = WarderHelper::getPackage();
         $this->redirect($this->router->route($warder->get('frontend.redirect.login', 'home')));
         return;
     }
     parent::prepareExecute();
 }
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     parent::prepareExecute();
     $this->view['email'] = $this->input->getEmail('email');
     $this->view['token'] = $this->input->get('token');
     // Check email and token
     $user = User::get(array('email' => $this->view['email']));
     if ($user->isNull()) {
         $this->backToConfirm(Translator::translate($this->langPrefix . 'user.not.found'));
         return;
     }
     if (!UserHelper::verifyPassword($this->view['token'], $user->reset_token)) {
         $this->backToConfirm('Invalid Token');
         return;
     }
 }
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     $return = $this->input->getBase64($this->package->get('frontend.login.return_key', 'return'));
     if (UserHelper::isLogin()) {
         if ($return) {
             $this->app->redirect(base64_decode($return));
         } else {
             $this->app->redirect($this->getHomeRedirect());
         }
         return;
     }
     if ($return) {
         $this->setUserState($this->getContext('return'), $return);
     }
     parent::prepareExecute();
 }
Exemple #9
0
 /**
  * authenticate
  *
  * @param Credential $credential
  *
  * @return  integer
  */
 public function authenticate(Credential $credential)
 {
     $loginName = $this->warder->getLoginName();
     if (!$credential->{$loginName} || !$credential->password) {
         $this->status = Authentication::EMPTY_CREDENTIAL;
         return false;
     }
     /** @var UserData $user */
     $user = User::get(array($loginName => $credential->{$loginName}));
     if ($user->isNull()) {
         $this->status = Authentication::USER_NOT_FOUND;
         return false;
     }
     if (!UserHelper::verifyPassword($credential->password, $user->password)) {
         $this->status = Authentication::INVALID_PASSWORD;
         return false;
     }
     $credential->bind($user);
     $this->status = Authentication::SUCCESS;
     return true;
 }
Exemple #10
0
 /**
  * doExecute
  *
  * @return  void
  */
 public function doExecute()
 {
     $faker = Factory::create();
     $pass = UserHelper::hashPassword(1234);
     foreach (range(1, 50) as $i) {
         $data = new Data();
         $data->name = $faker->name;
         $data->username = $faker->userName;
         $data->email = $faker->email;
         $data->password = $pass;
         $data->avatar = PravatarHelper::unique(600, uniqid($i));
         $data->group = 1;
         $data->blocked = 0;
         $data->activation = '';
         $data->reset_token = '';
         $data->last_reset = $faker->dateTime->format(DateTime::getSqlFormat());
         $data->last_login = $faker->dateTime->format(DateTime::getSqlFormat());
         $data->registered = $faker->dateTime->format(DateTime::getSqlFormat());
         $data->modified = $faker->dateTime->format(DateTime::getSqlFormat());
         $data->params = '';
         UserMapper::createOne($data);
         $this->outCounting();
     }
 }
 /**
  * doSave
  *
  * @param DataInterface $data
  *
  * @return  bool
  *
  * @throws ValidateFailException
  * @throws \Exception
  */
 protected function doSave(DataInterface $data)
 {
     $email = $this->input->getEmail('email');
     if (!$email) {
         throw new ValidateFailException(Translator::translate($this->langPrefix . 'message.user.not.found'));
     }
     $view = $this->getView();
     $user = User::get(array('email' => $email));
     if ($user->isNull()) {
         throw new ValidateFailException(Translator::translate($this->langPrefix . 'message.user.not.found'));
     }
     $token = UserHelper::getToken($user->email);
     $link = $this->router->route('forget_confirm', array('token' => $token, 'email' => $email), CoreRouter::TYPE_FULL);
     $password = new Password();
     $user->reset_token = $password->create($token);
     $user->last_reset = DateTime::create()->toSql();
     User::save($user);
     $view['user'] = $user;
     $view['token'] = $token;
     $view['link'] = $link;
     $body = $this->getMailBody($view);
     $this->sendEmail($user->email, $body);
     return true;
 }
 /**
  * prepareExecute
  *
  * @return  void
  */
 protected function prepareExecute()
 {
     if (UserHelper::isLogin()) {
         $warder = WarderHelper::getPackage();
         $this->redirect($this->router->route($warder->get('frontend.redirect.login', 'home')));
         return;
     }
     parent::prepareExecute();
     $this->token = UserHelper::getToken($this->data['email']);
     $this->data['activation'] = UserHelper::hashPassword($this->token);
 }
Exemple #13
0
 /**
  * save
  *
  * @param DataInterface|UserRecord $user
  *
  * @return bool
  * @throws ValidateFailException
  */
 public function save(DataInterface $user)
 {
     if ('' !== (string) $user->password) {
         $user->password = UserHelper::hashPassword($user->password);
     } else {
         unset($user->password);
     }
     unset($user->password2);
     $this->prepareDefaultData($user);
     $user->bind(User::save($user));
     return true;
 }
 /**
  * doSave
  *
  * @param DataInterface $data
  *
  * @return bool
  *
  * @throws ValidateFailException
  */
 protected function doSave(DataInterface $data)
 {
     $user = User::get(['email' => $this->data['email']]);
     if (!UserHelper::verifyPassword($this->data['token'], $user->activation)) {
         throw new ValidateFailException(Translator::translate($this->langPrefix . 'message.activate.fail'));
     }
     $user->activation = '';
     $user->blocked = 0;
     User::save($user);
     return true;
 }
Exemple #15
0
 /**
  * authorise
  *
  * @return  boolean
  */
 public static function authorise()
 {
     $config = Ioc::getConfig();
     $requestLogin = $config->get('route.extra.warder.require_login', true);
     return UserHelper::isLogin() || !$requestLogin;
 }