예제 #1
0
 public bool AuthenticateUser(IUser user, UserDataBase userDataBase)
 {
     if (string.IsNullOrEmpty(user.Name))
     {
         return(LoginCheck(user.Email, user.Password, userDataBase));
     }
     else
     {
         return(LoginCheck(user.Name, user.Password, userDataBase));
     }
 }
예제 #2
0
 public IUser Search(string name, UserDataBase userDataBase)
 {
     foreach (var item in UsersList)
     {
         if (item.Name == name)
         {
             return(item);
         }
     }
     return(null);
 }
예제 #3
0
        public void Add(IUser user, UserDataBase userDataBase)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("UserDataBase");
            }
            Authenticator authenticator = new Authenticator();

            if (authenticator.AuthenticateUser(user, userDataBase))
            {
                UsersList.Add(user);
            }
            else
            {
                Console.WriteLine("This username exists");
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            UserDataBase userDataBase = new UserDataBase();

            while (true)
            {
                Console.WriteLine("Input Login: "******"exit")
                {
                    break;
                }
                Console.WriteLine("Input Password: ");
                var  password = Console.ReadLine();
                User user     = new User(login, password);

                userDataBase.Add(user, userDataBase);
            }
            userDataBase.Dispose();
        }
예제 #5
0
 private bool LoginCheck(MailAddress email, string password, UserDataBase userDataBase)
 {
     foreach (var item in userDataBase.UsersList)
     {
         if (item.Email.Address == email.Address)
         {
             if (item.Password == password)
             {
                 Console.WriteLine(item.Time);
                 item.Time = DateTime.Now;
                 return(false);
             }
             else
             {
                 Console.WriteLine("Password is incorrect");
                 return(false);
             }
         }
     }
     return(true);
 }