public function executeNew(sfWebRequest $request) { if ($request->getMethod() != "POST") { return; } $this->username = $request->getPostParameter("username"); if (!$this->username) { return $this->setErrorMsg("Username is a required field!"); } $this->user = UserDAO::getUser($this->username); if ($this->user) { return $this->setErrorMsg("That username is already in use!"); } $this->password1 = $request->getPostParameter("password1"); $this->password2 = $request->getPostParameter("password2"); if (!$this->password1 || !$this->password2) { return $this->setErrorMsg("Password is a required field"); } if ($this->password1 != $this->password2) { return $this->setErrorMsg("Password and password confirm must match!"); } $this->email = $request->getPostParameter("email"); $this->user = UserDAO::createUser($this->username, $this->password1, $this->email); $this->login($this->user); $this->redirect("dashboard/index"); }
function __construct() { session_start(); if (isset($_SESSION[AppConstants::SESSION_USER]) === false) { $_SESSION[AppConstants::SESSION_USER] = ''; $_SESSION[AppConstants::SESSION_PASSWORD] = ''; } $user = $_SESSION[AppConstants::SESSION_USER]; $pass = $_SESSION[AppConstants::SESSION_PASSWORD]; $userDao = new UserDAO(); $this->_user_USR = $userDao->getUser($user, $pass); }
if (isset($_GET["status"])) { $status = $_GET["status"]; if ($status == 0) { $message = "password changed successfully"; } else { if ($status == 1) { $message = "password updation failed"; } else { $message = "password cannot be more than 15char(s)."; } } } if (!checkSession()) { redirect_to("index.php"); } $user = UserDAO::getUser($_SESSION["username"]); if (isset($_POST["newPassword"])) { if (strlen($newPassword) > 15) { redirect_to("admin.php?status=2"); } else { $user->password = $_POST["newPassword"]; UserDAO::changePassword($user); redirect_to("admin.php?status=0"); } } } catch (Exception $exception) { echo $exception->getMessage(); die; } include "partials/header.php"; ?>
public static function loginUser($email, $password) { $user = UserDAO::getUser($email); if ($user && password_verify($password, $user->getPassword())) { return $user; } else { return false; } }