public async Task <IHttpActionResult> ChangePasswordAsync(ChangePassword changePassword) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await AppUserManager.ChangePasswordAsync(User.Identity.GetUserId(), changePassword.CurrentPassword, changePassword.NewPassword); if (!result.Succeeded) { ModelState.AddModelErrorRange(result.Errors); return(BadRequest(ModelState)); } return(Ok("Hasło zostało zmienione")); }
public async Task <IHttpActionResult> PostAsync(UserModel userModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ApplicationUser user = (ApplicationUser)userModel; IdentityResult addUserResult = await AppUserManager.CreateAsync(user, userModel.Password); if (!addUserResult.Succeeded) { ModelState.AddModelErrorRange(addUserResult.Errors); return(BadRequest(ModelState)); } string token = await AppUserManager.GenerateEmailConfirmationTokenAsync(user.Id); const string format = "http://127.0.0.1:5500/#!/konto/activate/token={0}&user={1}"; AppUserManager.SendEmailAsync(user.Id, "Activate", new Emails.Register() { Address = string.Format(format, token, user.Id) }); return(Created(Url.Link("UserData", null), user)); }