Пример #1
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new UserEngine();
     }
     return self::$instance;
 }
Пример #2
0
/**
*
* @TODO do
*
*/
function pagelines_get_users($args)
{
    $users = new UserEngine();
    $u = $users->get_users($args);
    return $u;
}
Пример #3
0
 private function secondStepPost($inParam2)
 {
     if (!$this->request->isPostRequest()) {
         $this->response = Response::fourOhFour();
         return;
     }
     if (!AntiForgeryToken::getInstance()->validate()) {
         $this->response = Response::fiveHundred();
         return;
     }
     if (!Honeypot::getInstance()->validate()) {
         $this->response = Response::fiveHundred();
         return;
     }
     $token = Request::getPostParameter('token');
     $email = Request::getPostParameter('email');
     $newPassword = Request::getPostParameter('newPassword');
     $confirmNewPassword = Request::getPostParameter('confirmNewPassword');
     if ($token === false) {
         $this->response = Response::fiveHundred();
         return;
     }
     if ($email === false) {
         $this->response = Response::fiveHundred();
         return;
     }
     if ($newPassword === false) {
         $this->response = Response::fiveHundred();
         return;
     }
     if ($confirmNewPassword === false) {
         $this->response = Response::fiveHundred();
         return;
     }
     $token = preg_replace('/\\s+/', '', strip_tags($token));
     if ($inParam2 !== $token) {
         $this->response = Response::fiveHundred();
         return;
     }
     $forgotPasswordEngine = ForgotPasswordEngine::getInstance();
     $forgotPassword1 = $forgotPasswordEngine->getForgotPasswordByToken($token);
     if ($forgotPassword1 === false) {
         $this->response = Response::fiveHundred();
         return;
     }
     if (!$forgotPasswordEngine->forgotPasswordIsOfValidAge($forgotPassword1)) {
         $this->response = Response::fourOhFour();
         return;
     }
     $username = preg_replace('/\\s+/', '', strip_tags($email));
     $validator = new emailValidator();
     if (!$validator->validate($username)) {
         $this->showErrorMessageForForgotPasswordIdentity();
         $this->redirectOnError($inParam2);
         return;
     }
     $user = UserEngine::getInstance()->getUserByEmail($username);
     if ($user === false) {
         $this->showErrorMessageForForgotPasswordIdentity();
         $this->redirectOnError($inParam2);
         return;
     }
     $forgotPassword2 = $forgotPasswordEngine->getForgotPasswordByUserID($user->getUserID());
     if ($forgotPassword2 === false) {
         $this->showErrorMessageForForgotPasswordIdentity();
         $this->redirectOnError($inParam2);
         return;
     }
     if (!$forgotPasswordEngine->forgotPasswordIsOfValidAge($forgotPassword2)) {
         $this->showErrorMessageForForgotPasswordIdentity();
         $this->redirectOnError($inParam2);
         return;
     }
     if ($forgotPassword1->getID() !== $forgotPassword2->getID()) {
         $this->showErrorMessageForForgotPasswordIdentity();
         $this->redirectOnError($inParam2);
         return;
     }
     if (!$forgotPassword1->verify($forgotPassword2->getToken(), $forgotPassword2->getUserID())) {
         $this->showErrorMessageForForgotPasswordIdentity();
         $this->redirectOnError($inParam2);
         return;
     }
     if (!$forgotPassword2->verify($forgotPassword1->getToken(), $forgotPassword1->getUserID())) {
         $this->showErrorMessageForForgotPasswordIdentity();
         $this->redirectOnError($inParam2);
         return;
     }
     $minimumPasswordLength = $forgotPasswordEngine->getMinimumPasswordLength();
     if ($newPassword !== $confirmNewPassword) {
         $this->showErrorMessageForForgotPasswordNonMatch($minimumPasswordLength);
         $this->redirectOnError($inParam2);
         return;
     }
     if (!$forgotPasswordEngine->resetUsersPassword($forgotPassword1->getToken(), $forgotPassword2->getUserID(), $newPassword, $confirmNewPassword)) {
         $this->showErrorMessageForForgotPasswordNonMatch($minimumPasswordLength);
         $this->redirectOnError($inParam2);
         return;
     }
     $forgotPasswordEngine->removeForgotPassword($forgotPassword1);
     $this->showSuccessMessageForForgotPasswordChange();
     $this->response = Response::redirect(new Link("users/login"));
 }