public async Task <IActionResult> UpdateEmail(UpdateEmailModel model) { if (string.IsNullOrEmpty(model.Username)) { return(new JsonResult(new { success = false, message = "Username is required" })); } var foundUser = await _userManager.FindByNameAsync(model.Username); if (foundUser != null) { var result = await _userManager.SetEmailAsync(foundUser, model.Email); if (result.Succeeded) { // Remove the UserInfo Cache RemoveCachedUser(model.Username); var token = await _userManager.GenerateEmailConfirmationTokenAsync(foundUser); return(new JsonResult(new { success = true, data = token })); } else { return(new JsonResult(new { success = false, message = "Unable to update email address.", identityErrors = result.Errors })); } } return(new JsonResult(new { success = false, message = "User does not exist." })); }
/// <summary> /// Update user email /// </summary> /// <param name="model">Update email model</param> /// <returns>Api response</returns> public async Task <ApiOkResult> UpdateEmail(UpdateEmailModel model) { var user = await GetCurrentUser(); if (user == null) { throw new MRException(); } if (user.Status == UserStatus.Blocked) { throw new MRException(); } user.Email = model.Email; var updateResponse = await _appUserRepository.Replace(user); if (updateResponse == null) { throw new MRException(); } return(new ApiOkResult()); }
public async Task <IActionResult> Put(UpdateEmailModel model) { var command = model.Adapt <UpdateEmailCommand>(); command.UserId = CurrentUserId; return(Ok(await _mediator.Send(command))); }
public async Task <IActionResult> UpdateEmail([FromBody] UpdateEmailModel model) { if (!ModelState.IsValid) { return(BadModelResponse(ModelState)); } return(Ok(await _accountManager.UpdateEmail(model))); }
public async Task <ActionResult> _UpdateEmail(UpdateEmailModel model) { if (ModelState.IsValid) { OperationDetails result = await _userManagementService.UpdateUserEmail(UserId, model.Email); if (result.Succeeded) { TempData["PartialMessage"] = result.Message; } else { TempData["PartialMessage"] = result.Message; } } return(PartialView(model)); }
public ServiceResult UpdateEmail(UpdateEmailModel model) { new MerchantComponent().UpdateEmail(WorkContext.MerchantId, model.Email); return(Result_OK("")); }