aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/UserController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-04-22 15:47:52 +0800
committercrupest <crupest@outlook.com>2019-04-22 15:47:52 +0800
commit58edbb6661c8f7d147f438716b286aa84c6bcb14 (patch)
tree5285f03bbc10efe6319e9487bc1de453a8efd859 /Timeline/Controllers/UserController.cs
parenta2d8695d1e46d271bab40ea192afffee65f7538f (diff)
downloadtimeline-58edbb6661c8f7d147f438716b286aa84c6bcb14.tar.gz
timeline-58edbb6661c8f7d147f438716b286aa84c6bcb14.tar.bz2
timeline-58edbb6661c8f7d147f438716b286aa84c6bcb14.zip
Add change password api.
Diffstat (limited to 'Timeline/Controllers/UserController.cs')
-rw-r--r--Timeline/Controllers/UserController.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs
index 59c7a48c..552bfb2f 100644
--- a/Timeline/Controllers/UserController.cs
+++ b/Timeline/Controllers/UserController.cs
@@ -78,5 +78,22 @@ namespace Timeline.Controllers
throw new Exception("Uncreachable code.");
}
}
+
+ [HttpPost("userop/changepassword"), Authorize]
+ public async Task<IActionResult> ChangePassword([FromBody] ChangePasswordRequest request)
+ {
+ var result = await _userService.ChangePassword(User.Identity.Name, request.OldPassword, request.NewPassword);
+ switch (result)
+ {
+ case ChangePasswordResult.Success:
+ return Ok(ChangePasswordResponse.Success);
+ case ChangePasswordResult.BadOldPassword:
+ return Ok(ChangePasswordResponse.BadOldPassword);
+ case ChangePasswordResult.NotExists:
+ return Ok(ChangePasswordResponse.NotExists);
+ default:
+ throw new Exception("Uncreachable code.");
+ }
+ }
}
}