public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                // strip the .myshopify.com in case they added it
                string shopName = model.ShopName.Replace(".myshopify.com", String.Empty);

                // prepare the URL that will be executed after authorization is requested
                Uri requestUrl = this.Url.RequestContext.HttpContext.Request.Url;
                Uri returnURL = new Uri(string.Format("{0}{1}",
                    ConfigurationManager.AppSettings["Shopify.AppUrl"],
                    this.Url.Action("ShopifyAuthCallback", "Account")));

                var authorizer = new ShopifyAPIAuthorizer(shopName, ConfigurationManager.AppSettings["Shopify.ConsumerKey"], ConfigurationManager.AppSettings["Shopify.ConsumerSecret"]);
                var authUrl = authorizer.GetAuthorizationURL(new string[] { ConfigurationManager.AppSettings["Shopify.Scope"] }, returnURL.ToString());
                return Redirect(authUrl);
            }

            return View(model);
        }
        public void Login_UserCanLogin()
        {
            string returnUrl = "/Home/Index";
            string userName = "******";
            string password = "******";

            WebSecurity.Setup(s => s.Login(userName, password, false)).Returns(true);
            var model = new LoginModel
            {
                UserName = userName,
                Password = password
            };

            var result = Controller.Login(model, returnUrl) as RedirectResult;
            Assert.NotNull(result);
            Assert.AreEqual(returnUrl, result.Url);
        }
        public void Login_InvalidCredentialsRedisplaysLoginScreen()
        {
            string returnUrl = "/Home/Index";
            string userName = "******";
            string password = "******";

            WebSecurity.Setup(s => s.Login(userName, password, false)).Returns(false);
            var model = new LoginModel
            {
                UserName = userName,
                Password = password
            };

            var result = Controller.Login(model, returnUrl) as ViewResult;
            Assert.NotNull(result);
        }
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }