예제 #1
0
 /// <summary>
 /// Checks if the input user is a valid, existing user, with a correct password, and sets them to the current user.
 /// Also adds the stored voicetype to the user object that is authenticated.
 /// </summary>
 /// <param name="tUser">The user to authenticate, as an MPAiUser object. This is passed by reference.</param>
 /// <returns>True if the user exists already, false otherwise.</returns>
 public static bool AuthenticateUser(ref MPAiUser tUser)
 {
     // This changes the field, as the property's setter is designed to be used from outside the class, and would cause this to break.
     if (allUsers.Contains(tUser) && GetUser(tUser.getName()).codeCorrect(tUser.getCode()))
     {
         MPAiUser user = GetUser(tUser.getName());
         currentUser = user;    // Set the user as the current user.
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #2
0
 /// <summary>
 /// Override for equals().
 /// Two users with the same username are considered the same user.
 /// </summary>
 /// <param name="obj">The object to be compared to the current user.</param>
 /// <returns>True if the user and the object are the same thing, false otherwise.</returns>
 public override bool Equals(System.Object obj)
 {
     if (obj is MPAiUser)
     {
         MPAiUser otherUser = (MPAiUser)obj;
         if (userName == null || passWord == null)
         {
             return(false);
         }
         return(getName() == otherUser.getName());
     }
     else
     {
         return(false);
     }
 }
예제 #3
0
 /// <summary>
 /// Checks whether the input user already exists in the system.
 /// </summary>
 /// <param name="candidate">The user to check, as an MPAiUser.</param>
 /// <returns>True if the user is in the system, false if not.</returns>
 public static bool ContainsUser(MPAiUser candidate)
 {
     return(ContainsUser(candidate.getName()));
 }