示例#1
0
文件: UsersBL.cs 项目: slashgnr/CD
        public bool AddUser(HttpRequest request, string firstName, string lastname, string email, string username, string password, DateTime? birthdate, EGender eGender)
        {
            CD_Users user = new CD_Users();
            user.FirstName = firstName;
            user.LastName = lastname;
            user.Email = email;
            user.Username = username;
            SaltedHash saltedHash = new SaltedHash();
            string hashedPassword = string.Empty;
            string salt = string.Empty;

            saltedHash.GetHashAndSaltString(password, out hashedPassword, out salt);
            user.Password = hashedPassword;
            user.Salt = salt;
            user.BirthDate = birthdate;
            if (birthdate.HasValue)
            {
                user.BirthDateHeb = birthdate.Value.ToHebrewJewishDateString(true);
            }
            user.EGenderID = (int)eGender;
            user.LastVisitDate = DateTime.Now;
            user.TimeStamp = DateTime.Now;
            user.LastVisitIP = Utils.GetClientIPAddress(request);

            CD_DAL.Users.UsersDAL dal = new CD_DAL.Users.UsersDAL();
               int affectedRows = dal.AddNewUser(user);
               return affectedRows == 1;
        }
示例#2
0
文件: UsersBL.cs 项目: slashgnr/CD
        public bool IsUserExists(string username)
        {
            UsersDAL dal = new UsersDAL();
            bool isExists = false;
            CD_Users user = dal.GetUser(username);

            if (user != null)
            {
                isExists = true;
            }

            return isExists;
        }
示例#3
0
文件: UsersBL.cs 项目: slashgnr/CD
        public bool ValidateUser(string username, string password)
        {
            UsersDAL dal = new UsersDAL();
            bool isValid = false;
            CD_Users user = dal.GetUser(username);

            if (user != null)
            {
                SaltedHash saltedHash = new SaltedHash();
                isValid = saltedHash.VerifyHashString(password, user.Password, user.Salt);
            }

            return isValid;
        }
示例#4
0
文件: UsersBL.cs 项目: slashgnr/CD
        public long GetUserid(string username, string password)
        {
            UsersDAL dal = new UsersDAL();
            bool isValid = false;
            long lId = 0;
            CD_Users user = dal.GetUser(username);

            if (user != null)
            {
                SaltedHash saltedHash = new SaltedHash();
                isValid = saltedHash.VerifyHashString(password, user.Password, user.Salt);
            }
            if (isValid)
            {
                lId = user.ID;
            }

            return lId;
        }