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
commit80d686a8b875cce854e4291cbe4a53e7a03e3eff (patch)
tree5285f03bbc10efe6319e9487bc1de453a8efd859 /Timeline/Controllers/UserController.cs
parent407f97db0be86aa071802b67bfdeadc7703528c9 (diff)
downloadtimeline-80d686a8b875cce854e4291cbe4a53e7a03e3eff.tar.gz
timeline-80d686a8b875cce854e4291cbe4a53e7a03e3eff.tar.bz2
timeline-80d686a8b875cce854e4291cbe4a53e7a03e3eff.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.");
+ }
+ }
}
}