diff options
Diffstat (limited to 'Timeline/Controllers/UserController.cs')
-rw-r--r-- | Timeline/Controllers/UserController.cs | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs index fa2d37d8..02c09aab 100644 --- a/Timeline/Controllers/UserController.cs +++ b/Timeline/Controllers/UserController.cs @@ -43,9 +43,9 @@ namespace Timeline.Controllers /// <summary>
/// Get all users.
/// </summary>
- /// <response code="200">The user list.</response>
+ /// <returns>All user list.</returns>
[HttpGet("users")]
- [ProducesResponseType(typeof(UserInfo[]), StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<UserInfo[]>> List()
{
var users = await _userService.GetUsers();
@@ -54,12 +54,13 @@ namespace Timeline.Controllers }
/// <summary>
- /// Get a user info.
+ /// Get a user's info.
/// </summary>
/// <param name="username">Username of the user.</param>
- /// <response code="200">The user info.</response>
+ /// <returns>User info.</returns>
[HttpGet("users/{username}")]
- [ProducesResponseType(typeof(UserInfo), StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status404NotFound)]
public async Task<ActionResult<UserInfo>> Get([FromRoute][Username] string username)
{
try
@@ -75,16 +76,14 @@ namespace Timeline.Controllers }
/// <summary>
- /// Change a user's property. You have to be administrator in some condition.
+ /// Change a user's property.
/// </summary>
/// <param name="body"></param>
/// <param name="username">Username of the user to change.</param>
- /// <response code="200">Succeed to change the user and return the new user info.</response>
- /// <response code="401">You have not logged in.</response>
- /// <response code="403">You are not administrator.</response>
- /// <response code="404">The user to change does not exist.</response>
+ /// <returns>The new user info.</returns>
[HttpPatch("users/{username}"), Authorize]
- [ProducesResponseType(typeof(UserInfo), StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
@@ -134,11 +133,9 @@ namespace Timeline.Controllers /// Delete a user and all his related data. You have to be administrator.
/// </summary>
/// <param name="username">Username of the user to delete.</param>
- /// <response code="200">Succeeded to delete or the user does not exist.</response>
- /// <response code="401">You have not logged in.</response>
- /// <response code="403">You are not administrator.</response>
+ /// <returns>Info of deletion.</returns>
[HttpDelete("users/{username}"), AdminAuthorize]
- [ProducesResponseType(typeof(CommonDeleteResponse), StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
public async Task<ActionResult<CommonDeleteResponse>> Delete([FromRoute][Username] string username)
@@ -153,12 +150,9 @@ namespace Timeline.Controllers /// <summary>
/// Create a new user. You have to be administrator.
/// </summary>
- /// <response code="200">Succeeded to create a new user and return his user info.</response>
- /// <response code="400">Error code is 11020101 if a user with given username already exists.</response>
- /// <response code="401">You have not logged in.</response>
- /// <response code="403">You are not administrator.</response>
+ /// <returns>The new user's info.</returns>
[HttpPost("userop/createuser"), AdminAuthorize]
- [ProducesResponseType(typeof(UserInfo), StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
@@ -178,11 +172,8 @@ namespace Timeline.Controllers /// <summary>
/// Change password with old password.
/// </summary>
- /// <response code="200">Succeeded to change password.</response>
- /// <response code="400">Error code is 11020201 if old password is wrong.</response>
- /// <response code="401">You have not logged in.</response>
[HttpPost("userop/changepassword"), Authorize]
- [ProducesResponseType(typeof(void), StatusCodes.Status200OK)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
public async Task<ActionResult> ChangePassword([FromBody] ChangePasswordRequest request)
|