public async Task <ActionResult> ChangePassword([FromBody] PasswordChangeInputModel model) { ApplicationUser user = await this.userManager.GetUserAsync(this.User); IdentityResult result = await this.userManager.ChangePasswordAsync(user, model.CurrentPassword, model.NewPassword); return(result.ToActionResult()); }
public async Task <ActionResult> ChangePermissions(ChangePermissionsInputModel model) { ApplicationUser user = this.userManager.Users.FirstOrDefault(u => u.Id == model.Id); await this.ClearUserRoles(user); IdentityResult result = await this.userManager.AddToRolesAsync(user, model.Roles); return(result.ToActionResult()); }
public async Task <IActionResult> Register(RegisterInputModel model) { if (userService.Exists(x => x.Email == model.Email)) { return(BadRequest("User with the same email already exists.")); } User user = model.To <User>(); user.UserName = model.Email; IdentityResult result = await userManager.CreateAsync(user, model.Password); return(result.ToActionResult()); }