public async Task <IActionResult> ConfirmAccount(Guid userId, string code, CancellationToken cancellationToken = default(CancellationToken)) { try { var user = await this.authUserManager.GetUser(userId, cancellationToken); if (user != null && user.UserId.HasValue && !string.IsNullOrWhiteSpace(code)) { var token = WebUtility.UrlDecode(code); this.log.LogDebug($"Decoded token for userid: {user.UserId} is {token}"); var vm = new ConfirmAccountViewModel { AlreadyConfirmed = await this.authUserManager.IsAccountConfirmed(user.UserId.Value), Code = token }; return(this.View(vm)); } } catch (Exception ex) { this.log.LogError($"User requested confirm account but an error occurred. UserId is {userId}", ex); } return(this.RedirectToAction("Error", "Home")); //TODO: need to redirect to error page }
public async Task <IActionResult> ConfirmAccount(ConfirmAccountViewModel model, CancellationToken cancellationToken = default(CancellationToken)) { UserDto user = null; if (!this.ModelState.IsValid) { return(this.View(model)); } try { user = await this.authUserManager.GetUser(model.Email, cancellationToken); user.Password = model.Password; //user.StatusMasterKey = ?; TODO var updateResult = await this.authUserManager.UpdateUser(user, cancellationToken, model.Code); if (updateResult) { await this.authUserManager.ConfirmAccount(user.UserId.Value, cancellationToken); } /* any existing user will be logged out then user * will be redirected to client home login screen*/ return(this.RedirectToAction("Logout", "Logout")); } catch (Exception ex) { if (user == null) { this.log.LogInformation($"User requested password reset but was not found in system. Email was {model.Email}"); this.log.LogError("Error retrieving user", ex); //Don't reveal that the user does not exist } } return(this.RedirectToAction("Error", "Home")); //TODO: need to redirect to error page }