2024-01-18 11:49:38 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once "lib/account.php";
|
|
|
|
|
2024-01-31 23:07:12 +01:00
|
|
|
function endpoint($endpoint_data): array
|
2024-01-18 11:49:38 +01:00
|
|
|
{
|
2024-02-03 17:10:54 +01:00
|
|
|
print_r($endpoint_data);
|
2024-02-03 16:08:26 +01:00
|
|
|
|
2024-01-31 23:07:12 +01:00
|
|
|
return match ($endpoint_data["action"]) {
|
2024-02-03 16:08:26 +01:00
|
|
|
//not logged in start
|
2024-01-31 23:07:12 +01:00
|
|
|
"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"]
|
|
|
|
),
|
2024-02-03 16:08:26 +01:00
|
|
|
//not logged in end
|
|
|
|
//logged in start
|
|
|
|
"logout" => doLogout(),
|
|
|
|
"change_password" => changePassword(
|
|
|
|
$endpoint_data["old_password"],
|
|
|
|
$endpoint_data["new_password"]
|
|
|
|
),
|
2024-01-31 23:07:12 +01:00
|
|
|
"update_user_profile" => updateUserProfile(
|
|
|
|
$endpoint_data["first_name"],
|
|
|
|
$endpoint_data["last_name"],
|
|
|
|
$endpoint_data["nickname"],
|
|
|
|
$endpoint_data["minecraft_nick"]
|
|
|
|
),
|
2024-02-03 16:08:26 +01:00
|
|
|
"get_user_info" => getUserInfo(),
|
|
|
|
//logged in end
|
|
|
|
//admin start
|
2024-01-31 23:07:12 +01:00
|
|
|
"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"]),
|
2024-02-03 16:08:26 +01:00
|
|
|
//admin end
|
|
|
|
default => ["Status" => "Fail", "message" => "Invalid action"],
|
2024-01-31 23:07:12 +01:00
|
|
|
};
|
2024-02-03 16:08:26 +01:00
|
|
|
}
|