Exemple #1
0
        /// <summary>
        /// 第三执行
        /// </summary>
        /// <param name="context"></param>
        public void OnActionExecuting(ActionExecutingContext context)
        {
            var request     = context.HttpContext.Request;
            var RequestPath = request.Path.ToString();

            if (RequestPath.Contains("Regist"))
            {
                var PhoneCode   = request.Form["Parameter[PhoneCode]"].ToString();
                var SessionCode = CacheFactory.Cache().GetCache <string>("PhoneCode").Trim();
                if (string.IsNullOrEmpty(SessionCode))
                {
                    context.Result = ObjectResultEx.Instance("请输入验证码", 1, RetrunMessge.SUCCESS, HttpCode.FAIL);
                }
                if (!SessionCode.Trim().Equals(PhoneCode))
                {
                    context.Result = ObjectResultEx.Instance("请输入正确的验证码", 1, RetrunMessge.SUCCESS, HttpCode.FAIL);
                }
                CacheFactory.Cache().RemoveCache("PhoneCode");
            }
            if (RequestPath.Contains("EnterpriseWeb/Edit") || RequestPath.Contains("EnterpriseWeb/Remove"))
            {
                //if (RequestPath.Contains("Edit"))
                //{
                //    if (string.IsNullOrEmpty(request.Form["Id"].ToString()))
                //    {
                //        return;
                //    }
                //    if (RequestPath.Contains("EditProBatchAttach"))
                //        return;
                //}
                //context.Result = new StatusCodeResult(403);
            }
            //if (RequestPath.Contains("RepastWeb/Edit") || RequestPath.Contains("RepastWeb/Remove"))
            //{
            //    if (RequestPath.Contains("Edit"))
            //    {
            //        if (string.IsNullOrEmpty(request.Form["Id"].ToString()))
            //        {
            //            return;
            //        }
            //    }
            //    if (RequestPath.Contains("RemoveScan"))
            //        return;
            //    context.Result = new StatusCodeResult(403);
            //}
            if (context.Filters.Any(t => (t as AllowAnonymousFilter) != null))
            {
                return;
            }
            if (request.Headers.ContainsKey("ApiKey") && request.Headers.ContainsKey("SysKey"))
            {
                String ApiKey = RSACryptionExtension.RSADecrypt(request.Headers["ApiKey"].FirstOrDefault());
                String SysKey = RSACryptionExtension.RSADecrypt(request.Headers["SysKey"].FirstOrDefault());
                if (ApiKey.Equals(Configer.ApiKey + DateTime.Now.ToShortDateString()) && SystemInfoKey.PrivateKey.Equals(SysKey))
                {
                    return;
                }
            }
            context.Result = new UnauthorizedResult();
        }
Exemple #2
0
        /// <summary>
        /// 退出登录
        /// </summary>
        /// <returns></returns>
        public static string LoginOut()
        {
            String HeadToken  = Configer.HttpContext.Request.Headers["Token"].ToString();
            String HeadSysKey = Configer.HttpContext.Request.Headers["SysKey"].ToString();
            String Token      = RSACryptionExtension.RSADecrypt(HeadToken);
            String SysKey     = RSACryptionExtension.RSADecrypt(HeadSysKey);

            CacheFactory.Cache().RemoveCache(Token);
            CacheFactory.Cache().RemoveCache(SysKey);
            return("退出成功!");
        }
Exemple #3
0
        /// <summary>
        /// 验证登录
        /// </summary>
        /// <returns></returns>
        public static CookieInfo Verification()
        {
            if (String.IsNullOrEmpty(Configer.HttpContext.Request.Headers["Token"].ToList().FirstOrDefault()))
            {
                return(null);
            }
            String     Token  = RSACryptionExtension.RSADecrypt(Configer.HttpContext.Request.Headers["Token"].ToString());
            CookieInfo Cookie = CacheFactory.Cache().GetCache <CookieInfo>(Token);

            SystemInfoKey.PrivateKey = Cookie == null ? null : Cookie.SysKey;
            return(Cookie);
        }