Example #1
0
        public ActionResult Index(DirectLinkOptions directLinkOptions, LogOnCredentials data)
        {
            try
            {
                data.Validate();
            }
            catch (RulesException ex)
            {
                ex.Extend(ModelState);
            }

            if (ModelState.IsValid && data.User != null)
            {
                AuthenticationHelper.CompleteAuthentication(data.User);
                if (Request.IsAjaxRequest())
                {
                    return(Json(new
                    {
                        success = true,
                        isAuthenticated = true,
                        userName = data.User.Name
                    }));
                }

                if (directLinkOptions != null && directLinkOptions.IsDefined())
                {
                    return(RedirectToAction("Index", "Home", directLinkOptions));
                }

                return(RedirectToAction("Index", "Home"));
            }

            FillViewBagData();
            return(LogOnView());
        }
Example #2
0
        public ActionResult Index(bool?useAutoLogin, DirectLinkOptions directLinkOptions, LogOnCredentials data)
        {
            data.UseAutoLogin = useAutoLogin ?? true;
            data.NtUserName   = GetCurrentUser();

            try
            {
                data.Validate();
            }
            catch (RulesException ex)
            {
                ex.Extend(ModelState);
            }

            if (ModelState.IsValid && data.User != null)
            {
                AuthenticationHelper.CompleteAuthentication(data.User);
                if (Request.IsAjaxRequest())
                {
                    return(Json(new
                    {
                        success = true,
                        isAuthenticated = true,
                        userName = data.User.Name
                    }));
                }

                var redirectUrl = QPConfiguration.WebConfigSection.BackendUrl;
                if (directLinkOptions != null)
                {
                    redirectUrl = directLinkOptions.AddToUrl(redirectUrl);
                }

                return(Redirect(redirectUrl));
            }

            InitViewBag(directLinkOptions);
            return(LogOnView(data));
        }