public async Task <IActionResult> SetEmailAddress(int userId, [FromBody] ProfileChangeDto changesDto) { if (!this.VerifyUser(userId)) { return(Unauthorized()); } User user = await _repo.GetUser(userId); string token = await _userManager.GenerateChangeEmailTokenAsync(user, changesDto.EMail); await _mailer.SendConfirmationMail(user.Id, changesDto.EMail, token, true); return(Ok()); }
public async Task <IActionResult> ChangePassword(int userId, [FromBody] ProfileChangeDto changesDto) { if (!this.VerifyUser(userId)) { return(Unauthorized()); } bool changed = await _repo.ChangePassword(userId, changesDto.CurrentPassword, changesDto.Password); if (changed) { return(NoContent()); } throw new Exception("Error updating E-Mail address"); }
public async Task <IActionResult> SetDisplayName(int userId, [FromBody] ProfileChangeDto changesDto) { if (!this.VerifyUser(userId)) { return(Unauthorized()); } User user = await _repo.GetUser(userId); user.DisplayName = changesDto.DisplayName; if (await _repo.SaveAll()) { return(NoContent()); } throw new Exception("Error updating display name"); }