Skip to content

Commit

Permalink
Update registration.
Browse files Browse the repository at this point in the history
  • Loading branch information
lewmilburn committed Jun 11, 2024
1 parent ed3a6c2 commit d627d07
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
31 changes: 26 additions & 5 deletions Processes/POST/Register.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,45 @@
exit;
}

$password = password_hash($password, PASSWORD_BCRYPT);

$uuid = Uuid::uuid4()->toString();

$SQL->Query("INSERT INTO `users`
(`id`, `uuid`, `email`, `password`, `firstname`, `middlename`, `surname`, `phone`, `birthdate`, `gender`, `preferred_name`, `preferred_pronouns`, `notes`)
if (!$SQL->Query("INSERT INTO `users`
(`id`, `uuid`, `role`, `email`, `password`, `code`)
VALUES
(
NULL,
'{$SQL->Escape($uuid)}',
0,
'{$SQL->Escape($email)}',
'{$SQL->Escape($password)}',
NULL
)
")) {
header('Location: /register?error=db');
exit;
}

if (!$SQL->Query("INSERT INTO `user_details`
(`id`, `uuid`, `firstname`, `middlename`, `surname`, `phone`, `birthdate`, `gender`, `preferred_name`, `pronouns`)
VALUES
(
NULL,
'{$SQL->Escape($uuid)}',
'{$SQL->Escape($firstname)}',
'{$SQL->Escape($middlename)}',
'{$SQL->Escape($surname)}',
'{$SQL->Escape($phone)}',
'{$SQL->Escape($dob)}',
'{$SQL->Escape($gender)}',
'{$SQL->Escape($preferredName)}',
'{$SQL->Escape($pronouns)}',
NULL
'{$SQL->Escape($pronouns)}'
)
");
")) {
header('Location: /register?error=db');
exit;
}

header('Location: /dashboard');
exit;
7 changes: 4 additions & 3 deletions Router/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
use Starlight\HTTP\Router;

class Main extends Router {
public function register() {
public function register(): void
{
$this->GET('/','/Views/Homepage.php');

$this->GET('/login','/Views/Login.php');
$this->GET('/register','/Views/Register.php');

$this->GET('/auth/login','/Processes/POST/Login.php');
$this->GET('/auth/register','/Processes/POST/Register.php');
$this->POST('/auth/login','/Processes/POST/Login.php');
$this->POST('/auth/register','/Processes/POST/Register.php');
}
}

0 comments on commit d627d07

Please sign in to comment.