Exemple #1
0
        public ActionResult SetFirstPassword()
        {
            string email     = Request.Form["email"] ?? string.Empty;
            string password  = Request.Form["password"] ?? string.Empty;
            string orderbvin = Request.Form["orderbvin"] ?? string.Empty;

            SimpleResponse resp = new SimpleResponse();

            resp.Success = true;

            MerchantTribe.Commerce.Orders.Order order = MTApp.OrderServices.Orders.FindForCurrentStore(orderbvin);
            if (order == null)
            {
                resp.Success   = false;
                resp.Messages += "Order id was invalid for password reset. ";
            }
            else
            {
                if (order.CustomProperties.Where(y => (y.DeveloperId == "bvsoftware") &&
                                                 (y.Key == "allowpasswordreset") &&
                                                 (y.Value == "1")).Count() < 1)
                {
                    resp.Success   = false;
                    resp.Messages += "This order does not allow password reset anymore. Please use the 'Forgot Password' link when signing in. ";
                }
            }

            if (password.Trim().Length < WebAppSettings.PasswordMinimumLength)
            {
                resp.Success   = false;
                resp.Messages += "Password must be at least " + WebAppSettings.PasswordMinimumLength + " characters long. ";
            }

            if (resp.Success)
            {
                MTApp.MembershipServices.ResetPasswordForCustomer(email, password);

                // Turn off reset key so that this can only happen once.
                var prop = order.CustomProperties.Where(y => (y.DeveloperId == "bvsoftware") &&
                                                        (y.Key == "allowpasswordreset") &&
                                                        (y.Value == "1")).FirstOrDefault();
                if (prop != null)
                {
                    prop.Value = "0";
                }
                MTApp.OrderServices.Orders.Update(order);
            }

            return(new PreJsonResult(MerchantTribe.Web.Json.ObjectToJson(resp)));
        }
        public static string RenderYahooTracker(MerchantTribe.Commerce.Orders.Order o, string accountId)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<SCRIPT language=\"JavaScript\" type=\"text/javascript\">" + System.Environment.NewLine);
            sb.Append("<!-- Yahoo! Inc." + System.Environment.NewLine);
            sb.Append("window.ysm_customData = new Object();" + System.Environment.NewLine);
            sb.Append("window.ysm_customData.conversion = \"transId=" + o.OrderNumber + ",currency=USD,amount=" + o.TotalGrand + "\";" + System.Environment.NewLine);
            sb.Append("var ysm_accountid  = \"" + accountId + "\";" + System.Environment.NewLine);
            sb.Append("document.write(\"<SCR\" + \"IPT language='JavaScript' type='text/javascript' \"" + System.Environment.NewLine);
            sb.Append(" + \"SRC=//\" + \"srv1.wa.marketingsolutions.yahoo.com\" + " + System.Environment.NewLine);
            sb.Append("\"/script/ScriptServlet\" + \"?aid=\" + ysm_accountid " + System.Environment.NewLine);
            sb.Append(" + \"></SCR\" + \"IPT>\");" + System.Environment.NewLine);
            sb.Append("// -->" + System.Environment.NewLine);
            sb.Append("</SCRIPT>");

            return(sb.ToString());
        }
Exemple #3
0
        public ActionResult AjaxSignIn()
        {
            string email    = Request.Form["email"] ?? string.Empty;
            string password = Request.Form["password"] ?? string.Empty;

            SignInViewModel posted = new SignInViewModel()
            {
                Email    = email,
                Password = password
            };

            ValidateModelResponse validated = ValidateLoginModel(posted, false);

            if (validated.Success)
            {
                string errorMessage = string.Empty;
                string userId       = string.Empty;
                if (MTApp.MembershipServices.LoginCustomer(posted.Email.Trim(),
                                                           posted.Password.Trim(),
                                                           ref errorMessage,
                                                           this.Request.RequestContext.HttpContext,
                                                           ref userId, MTApp))
                {
                    MerchantTribe.Commerce.Orders.Order cart = SessionManager.CurrentShoppingCart(MTApp.OrderServices, MTApp.CurrentStore);
                    if (cart != null && !string.IsNullOrEmpty(cart.bvin))
                    {
                        cart.UserEmail = posted.Email.Trim();
                        cart.UserID    = userId;
                        MTApp.CalculateOrderAndSave(cart);
                        SessionManager.SaveOrderCookies(cart, MTApp.CurrentStore);
                    }
                    validated.Success = true;
                }
                else
                {
                    validated.ResultMessages.Add(errorMessage);
                    validated.Success = false;
                }
            }

            return(new PreJsonResult(MerchantTribe.Web.Json.ObjectToJson(validated)));
        }
Exemple #4
0
        public ActionResult SignInPost(SignInViewModel posted)
        {
            SignInSetup();

            if (Request.QueryString["mode"] != null)
            {
                posted.Mode = Request.QueryString["mode"];
            }

            ValidateModelResponse validated = ValidateLoginModel(posted, false);

            if (validated.Success == false)
            {
                foreach (string s in validated.ResultMessages)
                {
                    FlashWarning(s);
                }
            }
            else
            {
                string errorMessage = string.Empty;
                string userId       = string.Empty;
                if (MTApp.MembershipServices.LoginCustomer(posted.Email.Trim(),
                                                           posted.Password.Trim(),
                                                           ref errorMessage,
                                                           this.Request.RequestContext.HttpContext,
                                                           ref userId, MTApp))
                {
                    MerchantTribe.Commerce.Orders.Order cart = SessionManager.CurrentShoppingCart(MTApp.OrderServices, MTApp.CurrentStore);
                    if (cart != null && !string.IsNullOrEmpty(cart.bvin))
                    {
                        cart.UserEmail = posted.Email.Trim();
                        cart.UserID    = userId;
                        MTApp.CalculateOrderAndSave(cart);
                        SessionManager.SaveOrderCookies(cart, MTApp.CurrentStore);
                    }

                    // if we got here from checkout, return to checkout
                    if (posted.Mode.Trim().ToLowerInvariant() == "checkout")
                    {
                        return(Redirect("~/checkout"));
                    }
                    // otherwise send to account home
                    return(Redirect("~/account"));
                }
                else
                {
                    string errorMessage2 = string.Empty;
                    // Failed to Login as Customer, Try admin account
                    if (MTApp.AccountServices.LoginAdminUser(posted.Email.Trim(),
                                                             posted.Password.Trim(),
                                                             ref errorMessage2,
                                                             this.Request.RequestContext.HttpContext,
                                                             MTApp))
                    {
                        return(Redirect("~/bvadmin"));
                    }
                    this.FlashWarning(errorMessage);
                }
            }

            return(View(posted));
        }