Пример #1
0
        public IActionResult Index()
        {
            ViewBag.SiteSettings = ss;
            var loginInfo = _ua.AuthenticateUser(this);

            if (loginInfo == null)
            {
                ViewBag.UserIsAuthenticated = false;
                ViewBag.UserIdentityName    = "";
                ViewBag.UserIdentityKey     = "";
            }
            else
            {
                // lets give them a cookie
                if (string.IsNullOrEmpty(loginInfo.Hmac))
                {
                    var cookieValue = _ua.GenerateCookie(loginInfo);
                    HttpContext.Response.Cookies.Append(UserAuthenticator.CookieName, cookieValue);
                }

                ViewBag.UserIsAuthenticated = true;
                ViewBag.UserIdentityName    = loginInfo.FriendlyName;
                ViewBag.UserIdentityKey     = loginInfo.UserId;
            }

            return(View());
        }