예제 #1
0
파일: UserBL.cs 프로젝트: zero1036/TGNet
        /// <summary>
        /// 验证BC端登陆用户信息
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="passWord"></param>
        public bool VerifyBCLoginUser(string userId, string passWord)
        {
            //先通过session,查出用户ID
            string pUserID = SysCurUser.GetCurUserID();

            LogSwHelper.Sing.Info("BC验证,从Session中获取userid:" + pUserID);
            if (!string.IsNullOrEmpty(pUserID))
            {
                CurUserM pUser = SysCurUser.GetCurUser();
                if (pUser != null && pUser.UserId == userId)
                {
                    var pwdCode = Emperor.UtilityLib.CyberUtils.Encrypt("Aes", 256, passWord, "TW" + userId);
                    if (pUser.Password == pwdCode)
                    {
                        return(true);
                    }
                }
            }
            else
            {
                //适用于登陆验证,通过用户ID获取当前用户
                UserTM pUser = GetUserByID(userId, _da.GetUserByUserID);
                if (pUser != null && pUser.UserId == userId)
                {
                    var pwdCode = Emperor.UtilityLib.CyberUtils.Encrypt("Aes", 256, passWord, "TW" + userId);
                    if (pUser.Password == pwdCode)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #2
0
        /// <summary>
        /// 获取当前用户所属租户ID
        /// </summary>
        /// <returns></returns>
        protected int GetCurTid()
        {
            var pCurSysUser = SysCurUser.GetCurUser();

            if (pCurSysUser != null)
            {
                return(pCurSysUser.Tid);
            }
            return(-1);
        }
예제 #3
0
파일: TagDA.cs 프로젝트: zero1036/TGNet
        /// <summary>
        /// 获取标签
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public DataTable GetTags()
        {
            var tid = SysCurUser.GetCurUser().Tid;

            if (tid == -1)
            {
                return(null);
            }

            DataTable dt = _pADO.Query(SqlScriptHelper.Tag.SEL_TAGS, new string[] { "?tid" }, new object[] { tid }, string.Empty);

            return(dt);
        }
예제 #4
0
        /// <summary>
        /// 获取租户所有部门对应用户关系
        /// </summary>
        /// <returns></returns>
        public DataTable GetDep2UserRel()
        {
            var tid = SysCurUser.GetCurUser().Tid;

            if (tid == -1)
            {
                return(null);
            }

            DataTable dt = _pADO.Query(SqlScriptHelper.Department.SEL_DEP2USERREL, new string[] { "?tid" }, new object[] { tid }, string.Empty);

            return(dt);
        }
예제 #5
0
        /// <summary>
        /// 获取用户
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public DataTable GetUsers()
        {
            var tid = SysCurUser.GetCurUser().Tid;

            if (tid == -1)
            {
                return(null);
            }
            var tbNameFull = SysCurUser.GetCurUser().TenantRoutes.Single(t => t.TbName == SqlScriptHelper.T_USER).TbNameFull;

            var       sFIlter = string.Format(SqlScriptHelper.SEL_SINGLEUSER, tbNameFull, "1=1");
            DataTable dt      = _pADO.Query(sFIlter, new string[] { "?tid" }, new object[] { tid }, string.Empty);

            return(dt);
        }
예제 #6
0
        public HttpResponseMessage Login([FromBody] UserPostParamVM param)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            string strUserName  = param.Account;
            string strPassword  = param.Password;
            var    accountModel = new AccountHelper();

            try
            {
                //验证用户是否是系统注册用户
                if (accountModel.ValidateUserLogin(strUserName, strPassword))
                {
                    //创建用户ticket信息
                    var token = accountModel.CreateLoginUserTicket(strUserName, strPassword);

                    ////读取用户权限数据
                    //accountModel.GetUserAuthorities(strUserName);

                    //获取当前用户
                    var pCurUser = SysCurUser.GetCurUser();

                    response = Request.CreateResponse(HttpStatusCode.OK, new { userId = pCurUser.UserId, role = 1, token = token, time = 0, menu = pCurUser.Menus.Select(p => p.Href).Where(p => !string.IsNullOrEmpty(p)).ToList() });
                }
                else
                {
                    response = Request.CreateResponse(HttpStatusCode.Forbidden);
                    //response = Request.CreateResponse(HttpStatusCode.OK, new { userId = string.Empty, role = 1, token = string.Empty, time = 0 });
                }
            }
            catch (Exception ex)
            {
                Logger.Log4Net.Info("登陆错误" + ex.Message);
                response = Request.CreateResponse <string>(HttpStatusCode.InternalServerError, ex.Message);
            }
            return(response);
        }