Esempio n. 1
0
        static void Main(string[] args)
        {
            string username = null, password = null;

            AskLoginCredentials(ref username, ref password);

            LoginValidator validator = LoginValidator.From(username, password, PrintError);

            while (!validator.ValidCredentials())
            {
                AskLoginCredentials(ref username, ref password);

                if (validator.LoginAttemptsExceeded())
                {
                    Console.WriteLine("Надвишен брой опити за login");

                    return;
                }
            }

            User user = service.getUser(username, password);

            if (user == null)
            {
                Console.WriteLine("Несъществуващ потребител!");
                return;
            }

            if (user.Role == UserRole.ADMIN)
            {
                HandleAdminActions();
            }
            else
            {
                Console.WriteLine($"Username={user.Username}");
                Console.WriteLine($"Password={user.Password}");
                Console.WriteLine($"FacultyNumber={user.FacultyNumber}");
                Console.WriteLine($"Role={user.Role}");
                Console.WriteLine($"Created={user.CreatedAt}");
                Console.WriteLine($"ActiveUntil={user.ActiveUnitl}");
            }
        }