//private readonly User _user;
        //public UserManagerService()
        //{
        //    _user = new User
        //    {
        //        Id = 1,
        //        FirstName = "Rector",
        //        LastName = "Liu",
        //        Email = "*****@*****.**",
        //        LoginName = "admin",
        //        Password = "******",
        //        Roles = "admin"
        //    };
        //}
        public void SignIn(HttpContext httpContext, User user, bool isPersistent = false)
        {
            //ClaimsIdentity identity = new ClaimsIdentity(this.GetUserClaims(user), CookieAuthenticationDefaults.AuthenticationScheme);
            //ClaimsPrincipal principal = new ClaimsPrincipal(identity);

            //await httpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);
            httpContext.Session.Set(SessionKeys.SessionKey(SessionKeys.UserLoginModel), user);
        }
        public void OnPageHandlerExecuting(PageHandlerExecutingContext context)
        {
            if (!context.HttpContext.Session.SessionExists(SessionKeys.SessionKey(SessionKeys.UserLoginModel)))
            {
                var result  = new RedirectToPageResult("/account/login");
                var request = context.HttpContext.Request;
                var url     = context.HttpContext.Request.Path + context.HttpContext.Request.QueryString.Value;
                var query   = context.HttpContext.Request.Query;
                var dict    = new Microsoft.AspNetCore.Routing.RouteValueDictionary(new { returnUrl = url });
                //foreach (var item in query.Keys)
                //{
                //    dict.Add(item, query[item]);
                //}

                result.RouteValues = dict;
                context.Result     = result;
            }
        }
 public void SignOut(HttpContext httpContext)
 {
     //httpContext.SignOutAsync();
     httpContext.Session.Remove(SessionKeys.SessionKey(SessionKeys.UserLoginModel));
     httpContext.Session.Clear();
 }