public async Task <IActionResult> ChangePassword(ApplicationUserChangePasswordViewModel model, string returnPath) { var userId = this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid).Value; var name = this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.Name).Value; var userRecord = await this.applicationUserService.ChangePassword(userId, model.OldPassword, model.NewPassword, name); if (userRecord) { this.ShowMessage(Messages.PasswordChangeSuccess, Enums.MessageType.Success); } else { this.ShowMessage(Messages.InvalidOldPassword, Enums.MessageType.Error); } return(this.View()); }
public async Task <IActionResult> UserChangePassword(ApplicationUserChangePasswordViewModel model, string returnPath) { var userRecord = false; var emailid = this.User.Claims.FirstOrDefault(x => x.Type == System.Security.Claims.ClaimTypes.Email).Value; if (this.User.Identities.FirstOrDefault().AuthenticationType == Constants.ApplicationCookies) { userRecord = await this.userDetailService.UserChangePassword(emailid, model.OldPassword, model.NewPassword); } else { userRecord = await this.userDetailService.UserSetPassword(emailid, model.NewPassword); } if (userRecord) { return(this.Json(new { Status = true, Message = Messages.PasswordChangeSuccess })); } else { return(this.Json(new { Status = false, Message = Messages.InvalidOldPassword })); } }