aboutsummaryrefslogtreecommitdiff
path: root/Timeline
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-08-08 17:13:14 +0800
committer杨宇千 <crupest@outlook.com>2019-08-08 17:13:14 +0800
commit063321c90b8509249e65b49f39cf7d4f375305f6 (patch)
treecb3d30bbfa8b4c3f34912e687650bfad7a3dc422 /Timeline
parentd018e1c318646c6d7fecc8d3824129e9f1d5cf6c (diff)
downloadtimeline-063321c90b8509249e65b49f39cf7d4f375305f6.tar.gz
timeline-063321c90b8509249e65b49f39cf7d4f375305f6.tar.bz2
timeline-063321c90b8509249e65b49f39cf7d4f375305f6.zip
2 things.
1. Make Administrator in UserPutRequest nullable. 2. Remove default route.
Diffstat (limited to 'Timeline')
-rw-r--r--Timeline/Controllers/UserController.cs10
-rw-r--r--Timeline/Models/Http/User.cs2
-rw-r--r--Timeline/Startup.cs2
3 files changed, 3 insertions, 11 deletions
diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs
index 0992946c..28d9523a 100644
--- a/Timeline/Controllers/UserController.cs
+++ b/Timeline/Controllers/UserController.cs
@@ -18,8 +18,6 @@ namespace Timeline.Controllers
{
public const int Get_NotExists = -1001;
- public const int Put_NoPassword = -2001;
-
public const int Patch_NotExists = -3001;
public const int ChangePassword_BadOldPassword = -4001;
@@ -55,13 +53,7 @@ namespace Timeline.Controllers
[HttpPut("user/{username}"), AdminAuthorize]
public async Task<IActionResult> Put([FromBody] UserPutRequest request, [FromRoute] string username)
{
- if (request.Password == null) // This place will be refactored.
- {
- _logger.LogInformation("Attempt to put a user without a password. Username: {} .", username);
- return BadRequest();
- }
-
- var result = await _userService.PutUser(username, request.Password, request.Administrator);
+ var result = await _userService.PutUser(username, request.Password, request.Administrator.Value);
switch (result)
{
case PutResult.Created:
diff --git a/Timeline/Models/Http/User.cs b/Timeline/Models/Http/User.cs
index 3259a448..d45543fb 100644
--- a/Timeline/Models/Http/User.cs
+++ b/Timeline/Models/Http/User.cs
@@ -7,7 +7,7 @@ namespace Timeline.Models.Http
[Required]
public string Password { get; set; }
[Required]
- public bool Administrator { get; set; }
+ public bool? Administrator { get; set; }
}
public class UserPatchRequest
diff --git a/Timeline/Startup.cs b/Timeline/Startup.cs
index a28899f4..414bc705 100644
--- a/Timeline/Startup.cs
+++ b/Timeline/Startup.cs
@@ -89,7 +89,7 @@ namespace Timeline
app.UseAuthentication();
- app.UseMvcWithDefaultRoute();
+ app.UseMvc();
}
}
}