public async Task <IActionResult> IndexConfirmationPost(SignUpConfirmationViewModel model) { // Ensure default shell, We cannot sign-up from tenants if (!_shellSettings.IsDefaultShell()) { return(Unauthorized()); } // Validate if (model == null) { throw new ArgumentNullException(nameof(model)); } if (string.IsNullOrEmpty(model.SessionId)) { throw new ArgumentNullException(nameof(model.SessionId)); } if (string.IsNullOrEmpty(model.SecurityToken)) { throw new ArgumentNullException(nameof(model.SecurityToken)); } if (!ModelState.IsValid) { return(View(model)); } // Get the sign-up var signUp = await _signUpStore.GetBySessionIdAsync(model.SessionId); // Ensure we found the sign-up if (signUp == null) { return(NotFound()); } // Validate token var validToken = signUp.SecurityToken.Equals(model.SecurityToken, StringComparison.OrdinalIgnoreCase); if (validToken) { // Reset security token & mark email as confirmed signUp.SecurityToken = string.Empty; signUp.EmailConfirmed = true; await _signUpStore.UpdateAsync(signUp); // Redirect to sign-up confirmation return(RedirectToAction(nameof(SetUp), new RouteValueDictionary() { ["sessionId"] = signUp.SessionId })); } // The confirmation code is incorrect ViewData.ModelState.AddModelError(string.Empty, "The confirmation code is incorrect. Please try again!"); return(await IndexConfirmation(signUp.SessionId)); }
public SignUpConfirmationPage(SignUpAccountRequest model) { InitializeComponent(); BindingContext = new SignUpConfirmationViewModel(this.Navigation, model); }