Esempio n. 1
0
        private bool CheckUser(VLogin user)
        {
            var isExists = false;
            // 密文 Pwd
            var loginUser = auth.TPermUsers.Where(x => x.LoginName == user.Username).FirstOrDefault();

            if (loginUser == null)
            {
                return(false);
            }
            // 明文 user.Password
            var bytes = Encoding.Default.GetBytes(loginUser.Pwd);

            // 校验
            isExists = MD5Service.VerifyMd5Hash(MD5Service.MD5Hash, user.Password, loginUser.Pwd);

            return(isExists);
        }
Esempio n. 2
0
        public bool Create(VUserAdd user)
        {
            byte[] dataToEncrypt = Encoding.Default.GetBytes(user.Password);

            TPermUser tUser = new TPermUser();

            tUser.LoginName   = user.UserName;
            tUser.Pwd         = MD5Service.GetMd5Hash(MD5Service.MD5Hash, user.Password);
            tUser.NameCn      = user.NameCn;
            tUser.NameEn      = user.NameEn;
            tUser.TypeCode    = user.TypeCode;
            tUser.ExpireAt    = DateTime.UtcNow.AddYears(1);
            tUser.CreatedBy   = DefaultUser.UserName;
            tUser.CreatedTime = DateTime.UtcNow;

            wmsauth.TPermUsers.Add(tUser);

            return(wmsauth.SaveChanges() > 0);
        }