public virtual ActionResult SignIn(SignInForm model)
        {
            if (ModelState.IsValid)
            {
                // check for saml integration
                var establishment = _queryProcessor.Execute(new EstablishmentByEmail(model.UserName.GetEmailDomain())
                {
                    EagerLoad = new Expression<Func<Establishment, object>>[]
                    {
                        x => x.SamlSignOn,
                    }
                });
                if (establishment != null && establishment.HasSamlSignOn())
                {
                    return PushToSamlSsoExternal(establishment, model.ReturnUrl);
                }
                if (!string.IsNullOrWhiteSpace(model.Password) && _passwords.Validate(model.UserName, model.Password))
                {
                    _userSigner.SignOn(model.UserName, model.RememberMe);

                    return RedirectToAction(MVC.Identity.Tenantize(model.ReturnUrl));
                }
                if (string.IsNullOrWhiteSpace(model.Password))
                {
                    model.ShowPasswordField = true;
                }
            }

            return View(model);
        }
        public virtual ActionResult SignIn(string returnUrl)
        {
            // detect SAML SSO from skin cookie
            var tenancy = Request.Tenancy();
            if (tenancy != null && !string.IsNullOrWhiteSpace(tenancy.StyleDomain))
            {
                // get the establishment for this skin
                var styleDomain = tenancy.StyleDomain;
                if (!styleDomain.StartsWith("www."))
                    styleDomain = "www." + styleDomain;
                var establishment = _queryProcessor.Execute(
                    new EstablishmentByUrl(styleDomain)
                    {
                        EagerLoad = new Expression<Func<Establishment, object>>[]
                        {
                            e => e.SamlSignOn,
                        }
                    }
                );
                if (establishment != null && establishment.HasSamlSignOn())
                {
                    return PushToSamlSsoExternal(establishment, returnUrl);

                    // wait for the authn response
                    //return new EmptyResult();
                }
            }

            var model = new SignInForm();
#if DEBUG
            model.ShowPasswordField = true;
#endif

            return View(model);
        }