Ejemplo n.º 1
0
        public static User Login(User[] users, ValidationSevice validationSevice)
        {
            while (true)
            {
                Console.Write("Enter email: ");
                string email = Console.ReadLine();

                if (!validationSevice.ValidateEmail(email))
                {
                    Console.WriteLine("Enter valid email.");
                    continue;
                }

                User user = FindUser(email, users);
                if (user == null)
                {
                    Console.WriteLine("User does not exists");
                    continue;
                }

                // TODO: add 3 tries for password

                Console.WriteLine("Enter password");
                string password = Console.ReadLine();
                if (user.Password != password)
                {
                    Console.WriteLine("Password is incorect.");
                    continue;
                }

                return(user);
            }
        }
Ejemplo n.º 2
0
        private static string EnterEmail(ValidationSevice validationSevice, User[] users)
        {
            while (true)
            {
                Console.WriteLine("Enter email: ");
                string email = Console.ReadLine();
                if (!validationSevice.IsEmailUnique(email, users))
                {
                    Console.WriteLine("Email is already taken.");
                    continue;
                }

                if (!validationSevice.ValidateEmail(email))
                {
                    Console.WriteLine("Please enter valid mail.");
                    continue;
                }

                return(email);
            }
        }