Added http response code
This commit is contained in:
@@ -25,26 +25,23 @@ if(isset($_POST['login'])){
|
||||
$_SESSION['groupName'] = $groupName;
|
||||
$_SESSION['token'] = $token;
|
||||
$_SESSION['success'] = "You are now logged in";
|
||||
header('location: ../../../Frontend/index.php?login=success');
|
||||
exit();
|
||||
//header('location: ../../../Frontend/index.php?login=success');
|
||||
//exit();
|
||||
http_response_code(200);
|
||||
}
|
||||
else{
|
||||
session_destroy();
|
||||
header('location: ../../../Frontend/index.php?login=failed&?reason=token');
|
||||
exit();
|
||||
http_response_code(500);
|
||||
}
|
||||
|
||||
}else{
|
||||
session_destroy();
|
||||
header('location: ../../../Frontend/index.php?login=failed&?reason=password');
|
||||
exit();
|
||||
http_response_code(401);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
}else{
|
||||
session_destroy();
|
||||
header('location: ../../../Frontend/index.php?login=failed&?reason=group');
|
||||
exit();
|
||||
http_response_code(400);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,19 +12,17 @@ if(isAdmin()){
|
||||
$password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
|
||||
echo $password;
|
||||
if(!$password->save()){
|
||||
header("location: ../../../Frontend/Html/AdminPage.html?error=FailedSaveResetPassword");
|
||||
exit();
|
||||
http_response_code(500);
|
||||
}else{
|
||||
http_response_code(201);
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/Html/AdminPage.html?success=SavedResetPassword");
|
||||
exit();
|
||||
http_response_code(400);
|
||||
}
|
||||
|
||||
}else{
|
||||
header("location: ../../../Frontend/Html/AdminPage.html?error=FailedToResetPassword");
|
||||
exit();
|
||||
http_response_code(400);
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=NotAdmin");
|
||||
exit();
|
||||
http_response_code(401);
|
||||
}
|
||||
@@ -37,19 +37,18 @@ if(isset($_POST['regGroup'])){
|
||||
$password->remember_token = $token;
|
||||
|
||||
if(!$password->save()){
|
||||
return;
|
||||
http_response_code(500);
|
||||
}else{
|
||||
http_response_code(201);
|
||||
}
|
||||
|
||||
$_SESSION['groupName'] = $groupName;
|
||||
$_SESSION['token'] = $token;
|
||||
$_SESSION['success'] = "You are now logged in";
|
||||
header("location: ../../../Frontend/index.html?success=GroupRegister");
|
||||
exit();
|
||||
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=CouldNotValidatePassword");
|
||||
exit();
|
||||
http_response_code(400);
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=FailedRegister");
|
||||
exit();
|
||||
http_response_code(400);
|
||||
}
|
||||
|
||||
@@ -10,17 +10,17 @@ if(isLogin()){
|
||||
$group->group_name = $_POST['groupName'];
|
||||
$group->group_amount = $_POST['groupAmount'];
|
||||
$group->game_jam_id = $_POST['gameJamId'];
|
||||
$group->save();
|
||||
header("location: ../../../Frontend/index.html?success=YouHaveUpdated");
|
||||
exit();
|
||||
if(!$group->save()){
|
||||
http_response_code(500);
|
||||
}else{
|
||||
http_response_code(201);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=CouldNotUpdate");
|
||||
exit();
|
||||
http_response_code(400);
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=NotLogin");
|
||||
exit();
|
||||
http_response_code(401);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,16 +8,16 @@ if(isLogin()){
|
||||
$password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id);
|
||||
if(passwordValidate($pass = $_POST['password'])){
|
||||
$password->password = password_hash($pass,PASSWORD_DEFAULT);
|
||||
$password->save();
|
||||
header("location: ../../../Frontend/index.html?success=PasswordUpdated");
|
||||
exit();
|
||||
if(!$password->save()){
|
||||
http_response_code(500);
|
||||
}else{
|
||||
http_response_code(201);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=CouldNotUpdated");
|
||||
exit();
|
||||
http_response_code(400);
|
||||
}
|
||||
|
||||
}else{
|
||||
header("location: ../../../Frontend/index.html?error=NotLogin");
|
||||
exit();
|
||||
http_response_code(401);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user