Beispiel #1
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="code">工号</param>
        /// <param name="password">密码</param>
        /// <returns>登录结果</returns>
        public LoginValidateModel Login(string code, string password)
        {
            var encryptPwd = EncryptUtil.Md5Hash(password);
            var user       = _dbContext.Set <Employee>().Where(s => s.EmCode == code && (s.Password == encryptPwd || s.Password == password) && s.Disabled != true).FirstOrDefault();

            if (user != null)
            {
                var userDto = Mapper.Map <Employee, EmployeeDto>(user);
                userDto.Password = "";
                var token = EncryptUtil.AesEncrypt(string.Format("{0}|{1}", user.Id, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                return(new LoginValidateModel()
                {
                    Valid = true,
                    Token = token,
                    User = userDto,
                    Message = "Success",
                });
            }
            else
            {
                return(new LoginValidateModel()
                {
                    Valid = false,
                    Token = "",
                    User = null,
                    Message = "账号或密码不正确",
                });
            }
        }
Beispiel #2
0
    static int AesEncrypt(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <byte[]>(L, 2))
            {
                EncryptUtil obj  = (EncryptUtil)ToLua.CheckObject <EncryptUtil>(L, 1);
                byte[]      arg0 = ToLua.CheckByteBuffer(L, 2);
                byte[]      o    = obj.AesEncrypt(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <string>(L, 2))
            {
                EncryptUtil obj  = (EncryptUtil)ToLua.CheckObject <EncryptUtil>(L, 1);
                string      arg0 = ToLua.ToString(L, 2);
                string      o    = obj.AesEncrypt(arg0);
                LuaDLL.lua_pushstring(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes <byte[], string>(L, 2))
            {
                EncryptUtil obj  = (EncryptUtil)ToLua.CheckObject <EncryptUtil>(L, 1);
                byte[]      arg0 = ToLua.CheckByteBuffer(L, 2);
                string      arg1 = ToLua.ToString(L, 3);
                byte[]      o    = obj.AesEncrypt(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3 && TypeChecker.CheckTypes <string, string>(L, 2))
            {
                EncryptUtil obj  = (EncryptUtil)ToLua.CheckObject <EncryptUtil>(L, 1);
                string      arg0 = ToLua.ToString(L, 2);
                string      arg1 = ToLua.ToString(L, 3);
                string      o    = obj.AesEncrypt(arg0, arg1);
                LuaDLL.lua_pushstring(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: EncryptUtil.AesEncrypt"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Beispiel #3
0
        protected override void Initialize()
        {
            // 添加默认用户:管理员
            var admin = new Employee();

            admin.Id               = Guid.NewGuid().ToString();
            admin.CreateUserId     = Consts.SuperUserId.ToString();
            admin.LastUpdateUserId = Consts.SuperUserId.ToString();
            admin.CreateTime       = DateTime.Now;
            admin.LastUpdateTime   = DateTime.Now;
            admin.EmCode           = "admin";
            admin.EmName           = "管理员";
            admin.SiteId           = Consts.DefaultSiteId;
            admin.Password         = EncryptUtil.AesEncrypt("666666");
            _context.Set <Employee>().Add(admin);
        }