This commit is contained in:
2024-02-06 16:24:57 +01:00
parent 38895b1502
commit 72bd8b8bd1
15 changed files with 278 additions and 361 deletions

45
endpoints/account.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
require_once "lib/account.php";
function endpoint($endpoint_data): array
{
return match ($endpoint_data["action"]) {
//not logged in start
"login" => doLogin($endpoint_data["email"], $endpoint_data["password"]),
"register" => doRegister(
$endpoint_data["firstname"],
$endpoint_data["lastname"],
$endpoint_data["email"],
$endpoint_data["password"],
$endpoint_data["activation_token"]
),
//not logged in end
//logged in start
"logout" => doLogout(),
"change_password" => changePassword(
$endpoint_data["old_password"],
$endpoint_data["new_password"]
),
"update_user_profile" => updateUserProfile(
$endpoint_data["first_name"],
$endpoint_data["last_name"],
$endpoint_data["nickname"],
$endpoint_data["minecraft_nick"]
),
"update_user_email" => updateUserEmail(
$endpoint_data["email"]
),
"get_user_info" => getUserInfo(),
//logged in end
//admin start
"add_activation_codes" => addActivationCodes($endpoint_data["count"]),
"list_users" => listUsers(),
"list_activation_codes" => listActivationCodes(),
"delete_user" => deleteUser($endpoint_data["user_id"]),
"delete_activation_code" => deleteActivationCode($endpoint_data["activation_code"]),
//admin end
default => ["Status" => "Fail", "message" => "Invalid action"],
};
}