This commit is contained in:
Bruno Rybársky 2024-02-01 08:02:27 +01:00
parent a4fd20ad00
commit f3c7285463
2 changed files with 13 additions and 3 deletions

@ -8,7 +8,7 @@ function doLogin($email, $password){
global $mysqli; global $mysqli;
$found = false; $found = false;
if(!empty($email) && !empty($password)){ if(!empty($email) && !empty($password)){
$stmt = $mysqli->prepare("SELECT ID, FirstName, LastName, Nickname, PasswordHash, MinecraftNick, isAdmin FROM Users WHERE EMAIL = ? AND isActive = 1"); $stmt = $mysqli->prepare("SELECT ID, FirstName, LastName, Nickname, PasswordHash, MinecraftNick, PrivilegeLevel FROM Users WHERE EMAIL = ? AND isActive = 1");
$stmt->bind_param("s", $email); $stmt->bind_param("s", $email);
$stmt->execute(); $stmt->execute();
@ -18,7 +18,8 @@ function doLogin($email, $password){
$nickname = ""; $nickname = "";
$pwdhash = ""; $pwdhash = "";
$mcnick = ""; $mcnick = "";
$stmt->bind_result($idcko, $fname, $lname, $nickname, $pwdhash, $mcnick, false); $privilegelevel = 0;
$stmt->bind_result($idcko, $fname, $lname, $nickname, $pwdhash, $mcnick, $privilegelevel);
if($stmt->num_rows() > 0){ if($stmt->num_rows() > 0){
$stmt->fetch(); $stmt->fetch();
@ -29,12 +30,16 @@ function doLogin($email, $password){
$_SESSION["nickname"] = $nickname; $_SESSION["nickname"] = $nickname;
$_SESSION["email"] = $email; $_SESSION["email"] = $email;
$_SESSION["mcnick"] = $mcnick; $_SESSION["mcnick"] = $mcnick;
$_SESSION["isadmin"] = false; $_SESSION["privilegelevel"] = $privilegelevel;
$found = true; $found = true;
} }
} }
$stmt->close(); $stmt->close();
} }
if (!$found){
$_SESSION["ID"] = 0;
$_SESSION["privilegelevel"] = 0;
}
return $found ? ["status" => "success"] : ["status" => "fail"]; return $found ? ["status" => "success"] : ["status" => "fail"];
} }

@ -5,6 +5,11 @@ function renderDynamicPage($page_file)
return render(); return render();
} }
function CanViewPage($page_metadata)
{
}
function getPage($page_name = null){ function getPage($page_name = null){
global $routerConfig; global $routerConfig;
global $routerRequest; global $routerRequest;