public function __construct(Request $request) { $params = $request::getParameters(true); if (!isset($params[1])) { $this->response = Response::fourOhFour(); return; } if (empty($params[1])) { $this->response = Response::fourOhFour(); return; } $className = str_replace('.', '', trim($params[1])) . 'Form'; $file = EDUCASK_ROOT . "/site/modules/users/classes/{$className}.php"; if (!is_readable($file)) { $this->response = Response::fourOhFour(); return; } require_once $file; if (!class_exists($className)) { $this->response = Response::fiveHundred(); return; } $subModule = new $className($request); $this->response = $subModule->getResponse(); }
public function __construct(Request $request) { if (count($request->getParameters(true)) > 1) { $this->response = Response::fourOhFour(); return; } $user = CurrentUser::getUserSession(); if (!$user->isLoggedIn()) { $this->response = new Response(200, "@home/notLoggedIn.twig", "Welcome", "home"); return; } $this->response = new Response(200, "@home/main.twig", "Hi {$user->getFirstName()}", "home", $user); }
private static function getResponse($moduleInCharge) { $moduleEngine = ModuleEngine::getInstance(); $moduleInCharge = $moduleEngine->includeModule($moduleInCharge); if ($moduleInCharge === false) { return Response::fourOhFour(); } $module = new $moduleInCharge(Request::getInstance()); $response = $module->getResponse(); if (!is_object($response)) { return Response::fiveHundred(); } if (get_class($response) !== "Response") { return Response::fiveHundred(); } return $response; }
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")); }
public function __construct(Request $request) { if (count($request->getParameters(true)) > 2) { $this->response = Response::fourOhFour(); return; } $currentUser = CurrentUser::getUserSession(); if (!$currentUser->isLoggedIn()) { $this->response = Response::fourOhFour(); return; } $hookEngine = HookEngine::getInstance(); $hookEngine->runAction('userIsLoggingOut'); $currentUser->logOut(); session_regenerate_id(true); $hookEngine->runAction('userLoggedOut'); NoticeEngine::getInstance()->addNotice(new Notice("neutral", "You're now logged out.")); $this->response = Response::redirect(new Link("")); }
public function __construct(Request $request) { if (count($request->getParameters(true)) > 2) { $this->response = Response::fourOhFour(); return; } if (currentUser::getUserSession()->isLoggedIn()) { $this->response = Response::fourOhFour(); return; } $lockoutEngine = LockoutEngine::getInstance(); if ($lockoutEngine->isLockedOut($_SERVER['REMOTE_ADDR'])) { $minutesLeft = $this->minutesLeftInLockout(); $this->response = new Response(403, "@users/lockedOut.twig", "Locked Out", "lockedOut", $minutesLeft); return; } if ($request->isPostRequest()) { $this->response = $this->doLogIn(); return; } $this->response = new Response(200, "@users/login.twig", "Login", "login"); }