Ejemplo n.º 1
0
            public void OnActionExecuting(ActionExecutingContext context)
            {
                var mo = new Func.UserAuthAid(context.HttpContext).Get();

                if (mo.UserId == 0)
                {
                    context.Result = new ContentResult()
                    {
                        Content    = "unauthorized",
                        StatusCode = 401
                    };
                }
            }
Ejemplo n.º 2
0
            public void OnAuthorization(AuthorizationFilterContext context)
            {
                //验证登录标记是最新,不是则注销登录(即同一用户不允许同时在线,按缓存时间生效)
                if (context.HttpContext.User.Identity.IsAuthenticated && GlobalTo.GetValue <bool>("SingleSignOn"))
                {
                    var uinfo = new Func.UserAuthAid(context.HttpContext).Get();

                    string ServerSign = HelpFuncTo.GetLogonSign(uinfo.UserId);
                    if (uinfo.UserSign != ServerSign)
                    {
                        context.HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
                    }
                }
            }
Ejemplo n.º 3
0
            public void OnActionExecuting(ActionExecutingContext context)
            {
                bool isv = false;

                if (context.HttpContext.User.Identity.IsAuthenticated)
                {
                    var uinfo = new Func.UserAuthAid(context.HttpContext).Get();
                    isv = uinfo.UserId == GlobalTo.GetValue <int>("AdminId");
                }

                if (!isv)
                {
                    context.Result = new ContentResult()
                    {
                        Content    = "unauthorized",
                        StatusCode = 401
                    };
                }
            }
Ejemplo n.º 4
0
            public void OnActionExecuting(ActionExecutingContext context)
            {
                bool isv = false;

                if (context.HttpContext.User.Identity.IsAuthenticated)
                {
                    var uinfo = new Func.UserAuthAid(context.HttpContext).Get();

                    //已验证邮箱
                    using var db = new ContextBase();
                    uinfo        = db.UserInfo.Find(uinfo.UserId);
                    if (uinfo.UserId == 1 || uinfo.UserMailValid == 1)
                    {
                        isv = true;
                    }
                }

                if (!isv)
                {
                    var url = "/home/valid";
                    context.Result = new RedirectResult(url);
                }
            }