public ActionResult Index() { bool isCheckoutFlow = (bool)(TempData["IsCheckoutFlow"] ?? false); bool isActivationFlow = (bool)(TempData["IsActivationFlow"] ?? false); AuthenticationProvidersViewModel authenticationProvidersViewModel = new AuthenticationProvidersViewModel(); authenticationProvidersViewModel.AuthenticationDescriptions = SignInController.GetAuthenticationProviders(this.HttpContext); authenticationProvidersViewModel.IsCheckoutFlow = isCheckoutFlow; if (isActivationFlow) { string existingAccount = (string)(TempData["ActivatedEmail"] ?? string.Empty); string externalIdProvider = (string)(TempData["IdProvider"] ?? string.Empty); string message1 = string.Format( "Congratulations! We were able to succesfully link your '{0}' account with the Contoso account belonging to '{1}'", externalIdProvider, existingAccount); string message2 = "Please sign in to access your account."; authenticationProvidersViewModel.Messages = new string[] { message1, message2 }; authenticationProvidersViewModel.IsActivationFlow = true; } return(this.View(SignInController.SignInViewName, authenticationProvidersViewModel)); }
/// <summary> /// Action invoked to complete link up of an existing customer with an external identity. /// </summary> /// <returns>View for entering activation code to finalize account link up.</returns> public async Task <ActionResult> FinalizeAccountLinkUp() { string emailAddressOfExistingCustomer = this.Request.Form["Email"]; string activationCode = this.Request.Form["ActivationCode"]; if (string.IsNullOrEmpty(emailAddressOfExistingCustomer) || string.IsNullOrEmpty(activationCode)) { var message = "Both the email address and associated activation code must be provided."; RetailLogger.Log.OnlineStoreInvalidAccountLinkUpRequest(Utilities.GetMaskedEmailAddress(emailAddressOfExistingCustomer), activationCode, new NotSupportedException(message)); CustomerLinkUpPendingViewModel viewModel = new CustomerLinkUpPendingViewModel() { ErrorMessage = message, EmailAddressOfExistingCustomer = emailAddressOfExistingCustomer, ActivationCode = activationCode }; return(this.View(SignInController.UserPendingActivationViewName, viewModel)); } LinkToExistingCustomerResult result; try { RetailOperationsHandler retailOperationsHandler = new RetailOperationsHandler(ServiceUtilities.GetEcommerceContext(this.HttpContext)); result = await retailOperationsHandler.FinalizeLinkToExistingCustomer(emailAddressOfExistingCustomer, activationCode); } catch (Exception ex) { RetailLogger.Log.OnlineStoreInvalidAccountLinkUpRequest(Utilities.GetMaskedEmailAddress(emailAddressOfExistingCustomer), activationCode, ex); var message = "We were unable to process this activation code. Please try entering the code again."; CustomerLinkUpPendingViewModel viewModel = new CustomerLinkUpPendingViewModel() { ErrorMessage = message, EmailAddressOfExistingCustomer = emailAddressOfExistingCustomer, ActivationCode = activationCode }; return(this.View(SignInController.UserPendingActivationViewName, viewModel)); } this.TempData["IsActivationFlow"] = true; this.TempData["ActivatedEmail"] = result.EmailAddress; this.TempData["IdProvider"] = GetAuthenticationProviderName(result.ExternalIdentityProvider); var authProviders = SignInController.GetAuthenticationProviders(this.HttpContext); return(this.RedirectToAction(SignInController.DefaultActionName, SignInController.ControllerName)); }