Beispiel #1
0
        public void ApproveRegistration(string username)
        {
            if (username == null)
            {
                throw new ArgumentNullException("username");
            }
            if (RegistrationMode != UserRegistrationMode.Approved && RegistrationMode != UserRegistrationMode.PreApproved)
            {
                throw new NotSupportedException();
            }

            MockUser user = this.awaitingApproval.FirstOrDefault(u => u.Username == username);

            if (user == null)
            {
                return;
            }

            this.awaitingApproval.Remove(user);
            this.users.Add(user);
        }
Beispiel #2
0
        public LoginResult Login(string username, string password)
        {
            if (username == null)
            {
                throw new ArgumentNullException("username");
            }

            username = username.Trim().ToLower();

            if (this.bans.Any(b => !b.IsExpired && b.Username != null && b.Username.Trim().ToLower() == username))
            {
                return(new LoginResult(0, LoginResultState.FailedBanned));
            }

            LoginResultState state = LoginResultState.Success;
            MockUser         user  = users.FirstOrDefault(u => u.Username.Trim().ToLower() == username);

            if (user != null)
            {
                if (password == null)
                {
                    state = LoginResultState.FailedPassword;
                }
                else if (password.Trim().ToLower() != user.Password.Trim().ToLower())
                {
                    state = LoginResultState.FailedPassword;
                }
            }
            else
            {
                if (password != null)
                {
                    state = LoginResultState.FailedUsernameAndPassword;
                }
            }

            return(new LoginResult((user != null) ? user.UserId : Interlocked.Decrement(ref nextGuestId), state));
        }
Beispiel #3
0
 public void AddUser(MockUser user)
 {
     users.Add(user);
 }
Beispiel #4
0
 public void AddUser(MockUser user)
 {
     users.Add (user);
 }