Продолжение переписывания
This commit is contained in:
@@ -8,6 +8,21 @@ require_once("./index.php");
|
||||
|
||||
|
||||
|
||||
// Functions
|
||||
|
||||
/*
|
||||
* FUNCTION
|
||||
* Delete existing account
|
||||
*/
|
||||
function User_Delete (int $id): ReturnT {
|
||||
$s = $db->prepare("delete from users where id = ?");
|
||||
$s->bind_param("s", $id);
|
||||
|
||||
return new ReturnT(data: ($s->execute() !== false));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Methods
|
||||
|
||||
/*
|
||||
@@ -32,15 +47,12 @@ function User_Delete_Method (array $req): ReturnT {
|
||||
}
|
||||
|
||||
// If its attempt to delete other account
|
||||
if (!User_HasRole($THIS_USER, "admin") && $THIS_USER !== $id)
|
||||
if (!User_HasRole($THIS_USER, "admin").GetData() && $THIS_USER !== $id)
|
||||
return new ReturnT(err_code: E_ACS_INSUFROLE, err_desc: "you must be admin to delete other accounts");
|
||||
|
||||
// Actions
|
||||
|
||||
$s = $db->prepare("delete from users where id = ?");
|
||||
$s->bind_param("s", $id);
|
||||
|
||||
return new ReturnT(data: ($s->execute() !== false));
|
||||
return User_Delete($id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user