public UserAuth CreateUserAuth(UserAuth newUser, string password)
        {
            ABUserAuth ab_newuser = newUser.TranslateTo <ABUserAuth>();

            ValidateNewUser(ab_newuser, password);

            string salt;
            string hash;

            passwordHasher.GetHashAndSaltString(password, out hash, out salt);

            return(dbFactory.Run(db =>
            {
                AssertNoExistingUser(db, ab_newuser);

                var digestHelper = new DigestAuthFunctions();
                ab_newuser.DigestHa1Hash = digestHelper.CreateHa1(ab_newuser.UserName, DigestAuthProvider.Realm, password);
                ab_newuser.PasswordHash = hash;
                ab_newuser.Salt = salt;
                ab_newuser.CreatedDate = DateTime.UtcNow;
                ab_newuser.ModifiedDate = newUser.CreatedDate;

                db.Insert(ab_newuser);

                ab_newuser = db.GetById <ABUserAuth>(db.GetLastInsertId());
                return ab_newuser.TranslateTo <UserAuth>();
            }));
        }
        public ResultSet <Member> AddMember(MemberRegisterViewModel member)
        {
            var result = new ResultSet <Member>();

            /******This nickname is exists*******************/
            if (_memberRepository.GetMemberByNickname(member.NickName) != null)
            {
                result.Message = "This nickname is already in use";
                return(result);
            }


            if (!string.IsNullOrEmpty(member.Password) && member.Password.Length > 16)
            {
                result.Message = "Invalid password string length";
                return(result);
            }


            if (!string.IsNullOrEmpty(member.Password))
            {
                string hash, salt;
                _hashProvider.GetHashAndSaltString(member.Password, out hash, out salt);
                member.PasswordHash = hash;
                member.PasswordSalt = salt;
            }
            var newMember = _memberRepository.AddMember(member);

            if (newMember != null)
            {
                result.Success = true;
                result.Message = Messages.OperationSuccess;
                result.Object  = newMember;
            }

            return(result);
        }