/** * Adds a user to the list of users available to log in as. * Throws an exception if the user already exists. */ public void addUser(string username, string password, SECURITY_LEVEL level) { if (level == SECURITY_LEVEL.ROOT) { throw new InvalidUserException("Only one root user can exist."); } foreach (User u in allUsers) { if (u.username.Equals(username)) { throw new InvalidUserException("A user with that username already exists."); } } this.allUsers.Add(new User(username, password, level)); }
public User(string user, string pass, SECURITY_LEVEL level) { this.username = user; this.password = pass; this.adminLevel = level; }