Added http response code
This commit is contained in:
@@ -19,20 +19,18 @@ if(isset($_POST['aLogin'])){
|
||||
$_SESSION['userName'] = $userName;
|
||||
$_SESSION['admin'] = true;
|
||||
$_SESSION['success'] = "You are now logged in";
|
||||
header('location: ../../../Frontend/index.html?login=success');
|
||||
http_response_code(200);
|
||||
}else{
|
||||
session_destroy();
|
||||
header('location: ../../../Frontend/index.html?login=failed?reason=password');
|
||||
exit();
|
||||
echo "Fail to verify password";
|
||||
http_response_code(401);
|
||||
}
|
||||
|
||||
}else{
|
||||
session_destroy();
|
||||
header('location: ../../../Frontend/index.html?login=failed?reason=username');
|
||||
exit();
|
||||
echo "No user";
|
||||
http_response_code(401);
|
||||
}
|
||||
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=NoLogin");
|
||||
exit();
|
||||
http_response_code(400);
|
||||
}
|
||||
@@ -10,17 +10,13 @@ if (isAdmin()){
|
||||
$admin->user_name = $_POST["newUsername"];
|
||||
$admin->password = $_POST["newPassword"];
|
||||
if ($admin->save()){
|
||||
header("location: ../../../Frontend/Html/AdminPage.html?success=adminUserWasCreated");
|
||||
exit();
|
||||
http_response_code(201);
|
||||
}else{
|
||||
header("location: ../../../Frontend/Html/AdminPage.html?error=errorWhileSaving");
|
||||
exit();
|
||||
http_response_code(500);
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/Html/AdminPage.html?error=input:newAdmin.notSet");
|
||||
exit();
|
||||
http_response_code(400);
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=isNotAdministrator");
|
||||
exit();
|
||||
http_response_code(401);
|
||||
}
|
||||
Reference in New Issue
Block a user