Exemple #1
0
        /// <summary>
        /// url 权限路由
        /// </summary>
        /// <param name="callBack"></param>
        /// <param name="_biz">数据请求对象</param>
        /// <param name="_client">url编辑对象</param>
        /// <param name="userInfo">用户信息</param>
        /// <param name="dic">其他信息</param>
        /// <returns></returns>
        public static AuthMessage RouteUrl(string callBack, CJClient _client, SSOUser userInfo, CJDictionary dic)
        {
            try
            {
                userInfo.Password = null;
                dic = dic ?? new CJDictionary();
                //尝试从cookie中拿openid
                var openId = Tools.GetCookie(Stands.OpenIdCookie);
                //生成主站令牌 ps:如果有openid 使用openid作为令牌,如果没有openid  使用id
                var token = string.IsNullOrEmpty(openId) ? Guid.NewGuid().ToString().ToUpper() : openId;
                dic[CJClient.TOKEN] = token;

                var list = CacheHelper.Item_Get<List<Filters>>(Stands.FILTERS);
                //存储用户信息
                SaveLoginInfo(userInfo, token);
                try
                {
                    string configMsg;
                    if (list != null && list.Any(x => x.FlagValue == userInfo.FlagValue))
                    {
                        var redirect = list.First(x => x.FlagValue == userInfo.FlagValue);
                        callBack = redirect.Url;
                        configMsg = redirect.Message;
                    }
                    else
                    {
                        callBack = _client.BuildReturnUrl(callBack, dic);
                        configMsg = "登录成功!";
                    }
                    return new AuthMessage
                    {
                        Message = configMsg,
                        Url = callBack,
                        Status = userInfo.FlagValue
                    };

                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message);
                    throw new Exception("请检查xml文件:" + ex.Message);
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
                return new AuthMessage
                {
                    IsError = true,
                    Message = ex.Message
                };
            }
        }