示例#1
0
        public bool AddUser(TransportUser user)
        {
            //only add a user if there is noone else with the same username
            foreach (TransportUser u in _users)
            {
                if (u.GetUsername() == user.GetUsername())
                {
                    return(false);
                }
            }

            _users.Add(user);
            return(true);
        }
示例#2
0
        public bool AuthoriseUser(string username, string password)
        {
            foreach (TransportUser u in _users)
            {
                //search for the user
                if (username == u.GetUsername())
                {
                    //found user, check password
                    if (password == u.GetPassword())
                    {
                        //log user in
                        _loggedInUser = u;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            return(false);
        }
示例#3
0
 public void LogOutUser()
 {
     _loggedInUser = null;
 }