Example #1
0
        public ActionResult Updateqx(string UserName)
        {
            C_WxUser info = C_WxUser.GetUserByUserName(UserName);
            bool     rtn  = true;

            if (!string.IsNullOrWhiteSpace(info.UserName))
            {
                rtn = info.UpdateUserqx(UserName);
            }
            return(Content(rtn ? "ok" : "设置失败"));
        }
Example #2
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            _ActionName     = filterContext.ActionDescriptor.ActionName;
            _ControllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;

            string _ControllerType = filterContext.ActionDescriptor.ControllerDescriptor.ControllerType.ToString();

            if (_ControllerType != "AgentMobile.Controllers." + _ControllerName + "Controller")
            {
                filterContext.Result = GetErrorResult("若继承HBBaseController则该控制器只能使用默认后缀Controller和命名空间只能使用AgentMobile.Controllers", null);
                return;
            }
            string UserNameCookie = Common.GetCookieValue("WxUserName");

            UserName = UserNameCookie;
            if (string.IsNullOrWhiteSpace(UserName))
            {
                filterContext.Result = GetErrorResult(string.Empty, null, "login");
                return;
            }
            CurrentUser = C_WxUser.GetUserByUserName(UserName);

            if (CurrentUser == null)
            {
                filterContext.Result = GetErrorResult(string.Empty, null, "login");
                return;
            }
            if (string.IsNullOrWhiteSpace(CurrentUser.NickName))
            {
                filterContext.Result = GetErrorResult(string.Empty, null, "login");
                return;
            }
            if (CurrentUser.IsValid == false)
            {
                //拉黑用户
                filterContext.Result = GetErrorResult(string.Empty, null, "defriend");
                return;
            }

            if (Request.UserAgent.ToLower().Contains("micromessenger"))
            {
                IsWx = true;

                WXVariousApi VariousApi = new WXVariousApi();
                VariousApi.LoadWxConfigIncidentalAccess_token();
                string nonceStr  = WXVariousApi.GenerateNonceStr();
                string timestamp = WXVariousApi.GenerateTimeStamp();
                ViewData["signature"] = VariousApi.GetSignature(Request.Url.ToString(), nonceStr, timestamp);
                ViewData["nonceStr"]  = nonceStr;
                ViewData["timestamp"] = timestamp;
                ViewData["AppID"]     = VariousApi.WxConfig.APPID;
                ViewData["IsWx"]      = IsWx;
            }
            else
            {
                IsWx = false;
            }

            if (CurrentUser == null)
            {
                filterContext.Result = GetErrorResult(string.Empty, null, "login");
                return;
            }
        }