Most User endpoints

This commit is contained in:
2024-07-21 20:22:39 +02:00
parent b3c5841e36
commit 4b89a7e9ca
11 changed files with 102 additions and 28 deletions
+25
View File
@@ -45,4 +45,29 @@ class User
}
}
}
public function postSelf()
{
$token = Input::header("token");
$username = Input::post("username");
$password = Input::post("password");
$image = Input::file("image");
try {
return json_encode(MUser::getByToken($token)->update($username, $password, $image));
} catch (Exception $err) {
switch ($err->getMessage()) {
case "NotFound":
throw new Exception("User not Found", 404);
case "FailedUsername":
throw new Exception("Failed to update username", 500);
case "FailedPassword":
throw new Exception("Failed to update password", 500);
case "FailedImage":
throw new Exception("Failed to update image", 500);
default:
throw $err;
}
}
}
}