Example #1
0
 /**
  * Login user using $email and $password
  *
  * @param LoginForm $form
  * @throws WrongCredentialsException
  */
 public static function login(LoginForm $form)
 {
     $query = new SelectQuery(TUsers::_NAME, TUsers::EMAIL, $form->getEmail());
     $user = $query->fetchOneRow()->getOrElse(WrongCredentialsException::class);
     if (password_verify($form->getPassword(), $user[TUsers::PASSWORD])) {
         self::$session->set($user[TUsers::ID], "auth", "id");
     } else {
         throw new WrongCredentialsException();
     }
 }
Example #2
0
 protected function validate()
 {
     parent::validate();
     $this->_name = $this->name->orEmpty();
     if (Users::checkEmailConstraint($this->_email)) {
         throw new ValidatorException("User with this email already registered");
     }
 }