Esempio n. 1
0
        public object submit([FromBody] simpleUser siuser)
        {
            DBInit();//数据库初始化

            string             token;
            MongoHelper <User> helperUser = new MongoHelper <User>("MonitorPlatform");
            User user = helperUser.FindAll(x => x.usercode == siuser.usercode).First();

            if (user != null)
            {
                //验证密码
                if (user.pwd == DESEncryptor.DesEncrypt(siuser.password))
                {
                    SsoHelper.SignIn(new UserInfo {
                        UserCode = siuser.usercode, UserName = user.username, CreateDate = DateTime.Now
                    }, out token);
                    return(new { flag = true, username = user.username, token = token });
                }
            }

            return(new { flag = false, username = "", token = "" });
        }
Esempio n. 2
0
        public ServiceResponseData UserLogin()
        {
            string usercode = requestData.GetData <string>(0);
            string password = requestData.GetData <string>(1);

            User user    = NewObject <User>();
            bool islogin = user.UserLogin(usercode, password);

            if (islogin)
            {
                BaseUser      EbaseUser = user.GetUser(usercode);
                SysLoginRight right     = new SysLoginRight();
                right.UserId = EbaseUser.UserId;
                right.EmpId  = EbaseUser.EmpId;
                right.WorkId = EbaseUser.WorkId;

                Dept     dept      = NewObject <Dept>();
                BaseDept EbaseDept = dept.GetDefaultDept(EbaseUser.EmpId);
                if (EbaseDept != null)
                {
                    right.DeptId   = EbaseDept.DeptId;
                    right.DeptName = EbaseDept.Name;
                }

                BaseEmployee EbaseEmp = (BaseEmployee)NewObject <BaseEmployee>().getmodel(EbaseUser.EmpId);
                right.EmpName = EbaseEmp.Name;

                BaseWorkers EbaseWork = (BaseWorkers)NewObject <BaseWorkers>().getmodel(EbaseUser.WorkId);
                right.WorkName = EbaseWork.WorkName;

                if (EbaseWork.DelFlag == 0)
                {
                    string       regkey = EbaseWork.RegKey;
                    DESEncryptor des    = new DESEncryptor();
                    des.InputString = regkey;
                    des.DesDecrypt();
                    string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' });
                    if (ret.Length == 2 && ret[0] == EbaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now)
                    {
                        //ClientInfo.LoginRight = right;//缓存登录用户信息
                        //单点登录注册
                        Guid token = Guid.Empty;
                        SsoHelper.SignIn(usercode, new UserInfo()
                        {
                            UserId = usercode, UserName = right.EmpName, DeptName = right.DeptName, WorkName = right.WorkName
                        }, out token);


                        responseData.AddData(right.EmpName);
                        responseData.AddData(right.DeptName);
                        responseData.AddData(right.WorkName);
                        responseData.AddData(NewObject <Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList());
                        responseData.AddData(NewObject <Menu>().GetMenuList(right.UserId));
                        responseData.AddData(NewObject <Dept>().GetHaveDept(right.EmpId));
                        responseData.AddData(right);

                        return(responseData);
                    }
                    else
                    {
                        throw new Exception("登录用户的当前机构注册码不正确!");
                    }
                }
                else
                {
                    throw new Exception("登录用户的当前机构还未启用!");
                }
            }
            else
            {
                throw new Exception("输入的用户名密码不正确!");
            }
        }