public function login($email, $password) { $user = $this->find($email); if ($user) { if ($this->userRegisterInfo->password === HashGenerator::createHash($password, $this->userRegisterInfo->salt)) { Session::sessionPuts($this->sessionName, $this->userRegisterInfo->email); return true; } } return false; }
<!-- script set on forum submission --> <?php require_once 'php/InitFiles/Init.php'; // validate on submission if (ForumInput::forumExists($POST)) { if (Token::check(ForumInput::getForumInput('token'))) { // validate user input $validateRegistry = new ValidateUserInput(); $passed = $validateRegistry->validateForum($_POST, ValidateUserInput::registryRequirements()); if ($passed->getValidForum()) { // register user into database $salt = HashGenerator::createSalt(32); $newUserSession = new UserSession(); $newUserSession->registerUser(array('firstname' => ForumInput::getForumInput($FIRSTNAME), 'lastname' => ForumInput::getForumInput($LASTNAME), 'email' => ForumInput::getForumInput($EMAIL), 'salt' => $salt, 'password' => HashGenerator::createHash(ForumInput::getForumInput($PASSWORD), $salt), 'datejoined' => date('Y-m-d H:i:s'), 'gender' => substr(ForumInput::getForumInput($GENDER), 0, 1))); RedirectPage::to('index.php'); } else { print_r($validateRegistry->getErrors()); echo "Please Try again"; } } else { // cross site request forgery } } ?> <!-- Sign-Up--> <!-- Front-end --> <!DOCTYPE html> <html> <head> <title>Sign Up</title>