예제 #1
0
        /// <summary>
        /// 更改密码
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="passwordtype"></param>
        /// <param name="password"></param>
        private void changePassword(int userid, Entity.passwordType passwordtype, string password, bool encrypt = true)
        {
            if (encrypt)
            {
                password = Utils.bitcmsMD5(password);
            }
            var passwordInfo = this.getUserPasswordInfo(userid, passwordtype);

            if (passwordInfo == null)
            {
                passwordInfo = new UserPasswordInfo()
                {
                    UserId       = userid,
                    Password     = password,
                    PasswordType = passwordtype,
                    LastDate     = Config.SiteConfig.getLocalTime()
                };
                this.dbContext.UserPassword.Add(passwordInfo);
            }
            else
            {
                passwordInfo.Password = password;
                passwordInfo.LastDate = Config.SiteConfig.getLocalTime();
            }

            this.dbContext.SaveChanges();
        }
예제 #2
0
        /// <summary>
        /// 更新密码
        /// </summary>
        /// <param name="password"></param>
        /// <param name="newpassword"></param>
        public void updatePassword(int userid, Entity.passwordType passwordtype, string password, string newpassword)
        {
            var passwordInfo = this.getUserPasswordInfo(userid, passwordtype);

            if (passwordInfo != null)
            {
                this.dbContext.Entry <Entity.UserPasswordInfo>(passwordInfo).State = System.Data.Entity.EntityState.Modified;
                if (!string.IsNullOrEmpty(password))
                {
                    if (passwordInfo.Password.Equals(Utils.bitcmsMD5(password)))
                    {
                        this.changePassword(userid, passwordtype, newpassword);
                    }
                    else
                    {
                        Error   = Entity.Error.错误;
                        Message = "原密码不正确";
                    }
                }
                else
                {
                    this.changePassword(userid, passwordtype, newpassword);
                }
            }
            else
            {
                this.changePassword(userid, passwordtype, newpassword);
            }
        }
예제 #3
0
        /// <summary>
        /// 检查会员密码
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="password"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool checkUserPassword(int userid, string password, Entity.passwordType type)
        {
            var checkPwd = Utils.bitcmsMD5(password);

            return((from u in this.dbContext.User
                    join p in this.dbContext.UserPassword on u.UserId equals p.UserId
                    where u.UserId == userid && u.LockUser == 0 && p.PasswordType == type && p.Password.Equals(checkPwd)
                    select u).Count() > 0);
        }
예제 #4
0
        /// <summary>
        /// 查询管理员登陆
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public UserInfo checkLogin(string userName, string pwd, Entity.passwordType type)
        {
            var info = this.dbContext.User.FirstOrDefault(g => g.LockUser == 0 && g.UserName == userName);

            if (info != null)
            {
                //检查密码
                if (!this.checkUserPassword(info.UserId, pwd, type))
                {
                    info = null;
                }
                //最后登录时间
                updateLastLandDate(info);
            }

            return(info);
        }
예제 #5
0
 /// <summary>
 /// 更改密码
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="password"></param>
 public void updatePassword(int userid, Entity.passwordType passwordtype, string password)
 {
     this.updatePassword(userid, passwordtype, null, password);
 }
예제 #6
0
 /// <summary>
 /// 获取密码
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="passwordtype"></param>
 /// <returns></returns>
 private UserPasswordInfo getUserPasswordInfo(int userid, Entity.passwordType passwordtype)
 {
     return(this.dbContext.UserPassword.FirstOrDefault(g => g.UserId == userid && g.PasswordType == passwordtype));
 }