Esempio n. 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());
        }
Esempio n. 2
0
        public ActionResult Index(bool?useAutoLogin, DirectLinkOptions directLinkOptions)
        {
            var data = new LogOnCredentials
            {
                UseAutoLogin = useAutoLogin ?? true,
                NtUserName   = GetCurrentUser()
            };

            InitViewBag(directLinkOptions);
            return(LogOnView(data));
        }
Esempio n. 3
0
        public async Task <ActionResult> Index(bool?useAutoLogin, DirectLinkOptions directLinkOptions)
        {
            var data = new LogOnCredentials
            {
                UseAutoLogin = useAutoLogin ?? IsWindowsAuthentication(),
                NtUserName   = GetCurrentUser()
            };

            FillViewBagData(directLinkOptions);
            return(await LogOnView(data));
        }
Esempio n. 4
0
        private async Task <ActionResult> PostIndex(bool?useAutoLogin, LogOnCredentials data, string returnUrl)
        {
            data.UseAutoLogin = useAutoLogin ?? IsWindowsAuthentication();
            data.NtUserName   = GetCurrentUser();

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

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

                if (!string.IsNullOrEmpty(returnUrl))
                {
                    return(LocalRedirect(returnUrl));
                }

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

            FillViewBagData();
            return(await LogOnView(data));
        }
Esempio n. 5
0
 private ActionResult LogOnView(LogOnCredentials model) => Request.IsAjaxRequest() ? JsonHtml("Popup", model) : View(model);
Esempio n. 6
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));
        }
Esempio n. 7
0
 public async Task <ActionResult> JsonIndex(bool?useAutoLogin, [FromBody] LogOnCredentials data, string returnUrl)
 {
     return(await PostIndex(useAutoLogin, data, returnUrl));
 }