Most User endpoints
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,10 @@ paths:
|
||||
- User
|
||||
post:
|
||||
summary: Update user
|
||||
description: Update user with ID. Fields are updated in order username,password,image. If one fails, subsequent are not updated
|
||||
description:
|
||||
Update user with ID. Fields are updated in order username, password, image. If one fails, subsequent are not updated. <br>
|
||||
Use special ID <code>self</code> to update logged in user. <br>
|
||||
Requires logged in user to have admin permissions for any ID other than <code>self</code>. <br>
|
||||
security:
|
||||
- BasicAuth: []
|
||||
parameters:
|
||||
@@ -228,6 +231,7 @@ components:
|
||||
type: string
|
||||
image:
|
||||
type: string
|
||||
format: binary
|
||||
securitySchemes:
|
||||
BasicAuth:
|
||||
type: apiKey
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user