|
|
@@ -32,22 +32,28 @@ class Login_Action extends Action{
|
|
|
if (!isset($_POST['uname'], $_POST['password'])){
|
|
|
$this->code = 401;
|
|
|
$this->message = "Invalid username / password.";
|
|
|
- header("Location: " . URL::BASE . "login/");
|
|
|
- return;
|
|
|
+ http_response_code(401);
|
|
|
+ header("Location: " . URL::BASE . "login/?status=401");
|
|
|
+ die(); // So the erorr is not handled by the controller.
|
|
|
+ return 401;
|
|
|
}
|
|
|
$uname = SQLite3::escapeString($_POST['uname']);
|
|
|
if (strlen($uname) == 0){
|
|
|
$this->code = 401;
|
|
|
$this->message = "Invalid username / password.";
|
|
|
- header("Location: " . URL::BASE . "login/");
|
|
|
- return;
|
|
|
+ http_response_code(401);
|
|
|
+ header("Location: " . URL::BASE . "login/?status=401");
|
|
|
+ die(); // So the erorr is not handled by the controller.
|
|
|
+ return 401;
|
|
|
}
|
|
|
$password = SQLite3::escapeString($_POST['password']);
|
|
|
if (strlen($password) == 0){
|
|
|
$this->code = 401;
|
|
|
$this->message = "Invalid username / password.";
|
|
|
- header("Location: " . URL::BASE . "login/");
|
|
|
- return;
|
|
|
+ http_response_code(401);
|
|
|
+ header("Location: " . URL::BASE . "login/?status=401");
|
|
|
+ die(); // So the erorr is not handled by the controller.
|
|
|
+ return 401;
|
|
|
}
|
|
|
$password = hash('sha256', $password);
|
|
|
$statement = get_context()->get_db()->prepare("
|
|
|
@@ -70,8 +76,9 @@ class Login_Action extends Action{
|
|
|
if (!$r){
|
|
|
$this->code = 401;
|
|
|
$this->message = "Invalid username / password.";
|
|
|
- header("Location: " . URL::BASE . "login/");
|
|
|
- return;
|
|
|
+ header("Location: " . URL::BASE . "login/?status=401");
|
|
|
+ die(); // So the erorr is not handled by the controller.
|
|
|
+ return 401;
|
|
|
}
|
|
|
$user = $r["id"];
|
|
|
|
|
|
@@ -98,8 +105,7 @@ class Login_Action extends Action{
|
|
|
$this->code = 204;
|
|
|
$this->message = "No content.";
|
|
|
header("Location: " . URL::BASE);
|
|
|
- // TODO: Not redirecting?
|
|
|
die();
|
|
|
- return;
|
|
|
+ return 204;
|
|
|
}
|
|
|
}
|