Exemplo n.º 1
0
        private ActionResult GetSuccessUrlActionResult(AuthorizationLoginModel model)
        {
            // Redirect user to initially requested URL
            if (!String.IsNullOrEmpty(model.ReturnUrl))
            {
                return(Redirect(model.ReturnUrl));
            }

            return(Redirect("/"));
        }
Exemplo n.º 2
0
        public ActionResult Index(AuthorizationLoginModel model)
        {
            RebuildFormPostback(model);

            Session.Clear();
            FormsAuthentication.SignOut();

            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.Username, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
                    return(GetSuccessUrlActionResult(model));
                }

                // #### Check Able Commerce for an old customer ####
                //In future this whole section will get retired, you can retire CreateCustomerFromLegacyCustomer too
                IAbleCommerceLegacyLogin legacyLoginService = new AbleCommerceLoginService();

                var remoteLoginResponse = legacyLoginService.HandleLogin(model.Username, model.Password);

                var customer = remoteLoginResponse.ConvertToUmbracoMember(Services);

                if (customer != null)
                {
                    FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);

                    // flag this with Rusty's import Queue to pull this user into the new system
                    AbleCommerceImportQueue.Enqueue(model.Username, model.Password, Convert.ToInt32(customer.GetValue("ableCommerceId")));

                    return(GetSuccessUrlActionResult(model));
                }

                TempData[LoginErrorMessageKey] = LanguageDictionary.Alerts.InvalidUsernameOrPassword;
            }
            // Username not found either in Umbraco or Legacy system so bounce it back to the user
            //#TODO should this be localised/translated?

            return(View(model));
        }