Example #1
0
 public function signup($username, $address, $password, $repassword)
 {
     $db = new \Shop\Database();
     if (!$this->checkUsername($username)) {
         return false;
     }
     if (!$db->usernameAvailable($username)) {
         $this->errorMessage = "Username not available!";
         return false;
     }
     $passwordOK = $this->checkPasswordSecurity($password, $repassword);
     if ($passwordOK) {
         $hash = password_hash($password, PASSWORD_DEFAULT);
         $_SESSION['user'] = [$username, $address];
         $db->addUser($username, $this->untagAddress($address), $hash);
         return true;
     }
     return false;
 }