(airhead): ive no idea no lie
Signed-off-by: boris <boris@borishub.co.uk>
This commit is contained in:
@@ -2,20 +2,26 @@
|
||||
|
||||
require_once("Models/User.php");
|
||||
|
||||
// create user and dataset object
|
||||
$user = new User();
|
||||
$userDataSet = new UserDataSet();
|
||||
|
||||
if (isset($_POST["loginButton"])) {
|
||||
$username = $_POST["username"];
|
||||
$password = hash("sha256", $_POST["password"]);
|
||||
// hash password
|
||||
$password = (hash("sha256", $_POST["password"]));
|
||||
// if login error, show captcha
|
||||
if (isset($view->loginError)) {
|
||||
$generatedCaptcha = $_POST["generatedCaptcha"];
|
||||
$userCaptcha = $_POST["captcha"];
|
||||
|
||||
// if captcha wrong, say so
|
||||
if ($generatedCaptcha !== $userCaptcha) {
|
||||
$view->loginError = "Incorrect CAPTCHA.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// create a new student dataset object that we can generate data from
|
||||
// Error handling is VERY hacky, because of the lack of JS usage.
|
||||
if($userDataSet->checkUserCredentials($username, $password)) {
|
||||
@@ -29,14 +35,18 @@ if (isset($_POST["loginButton"])) {
|
||||
$queryParams = http_build_query(['modal' => 'true']);
|
||||
header("Location: {$_SERVER['PHP_SELF']}?$queryParams");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['closeButton'])) {
|
||||
unset($_GET['modal']);
|
||||
}
|
||||
if (isset($_POST["logoutButton"]))
|
||||
{
|
||||
$user->logout();
|
||||
}
|
||||
|
||||
// for login errors; show login modal until captcha solved
|
||||
if (isset($_GET['modal']) && $_GET['modal'] === 'true') {
|
||||
$view->loginError = $view->loginError ?? "Please solve the Captcha and try again.";
|
||||
}
|
||||
Reference in New Issue
Block a user