Пример #1
0
        public int Redirect(string input)
        {
            switch (input)
            {
            case "1":
                Console.Clear();
                SignInPage signIn = new SignInPage();
                DefaultMessages.PrintHeader();
                return(1);

            case "2":
                //Console.WriteLine("TWO");
                DefaultMessages.PrintHeader();
                return(2);

            case "3":
                //Console.WriteLine("THREE");
                return(3);

            default:
                DefaultMessages.PrintHeader();
                DefaultMessages.PrintErrorMessage("Wrong input !!! Please select one of the following options:");
                return(0);
            }
        }
Пример #2
0
        private void InsertNameAndLastName()
        {
            List <string> list = new List <string>(new string[] { "Name", "Last Name" });

            foreach (var item in list)
            {
                while (flag)
                {
                    ClearCurrentConsoleLine();
                    Console.Write("~$ Insert " + item + ": ");
                    string input = Console.ReadLine();
                    if (Regex.IsMatch(input, @"^[a-zA-Z]+$"))
                    {
                        if (item == "Name")
                        {
                            user.Name = input;
                        }
                        else
                        {
                            user.LastName = input;
                        }

                        Console.Clear();
                        PrintHeader();

                        break;
                    }
                    Console.SetCursorPosition(0, 5);
                    DefaultMessages.PrintErrorMessage("Wrong input !!! Please insert name that contains only letters.:");
                }
            }
        }
Пример #3
0
        private void InsertUsername()
        {
            while (true)
            {
                ClearCurrentConsoleLine();
                DefaultMessages.PrintUsernameConditionsMessage();
                Console.Write("~$ Insert username: "******"Wrong username !!! Please insert username following this conditions :");
            }
        }
Пример #4
0
        private void InsertPassword()
        {
            string pass1 = "";
            string pass2 = "";

            PasswordAdvisor.PasswordScore pwdScore;


            while (true)
            {
                for (int i = 0; i < 2; i++)
                {
                    while (true)
                    {
                        string         pass = "";
                        ConsoleKeyInfo key;
                        ClearCurrentConsoleLine();
                        if (i == 0)
                        {
                            Console.Write("~$ Insert password: "******"~$ Confirm password: "******"*");
                            }
                            else
                            {
                                if (key.Key == ConsoleKey.Backspace && pass.Length > 0)
                                {
                                    pass = pass.Substring(0, (pass.Length - 1));
                                    Console.Write("\b \b");
                                }
                            }
                        }
                        // Stops Receving Keys Once Enter is Pressed
                        while (key.Key != ConsoleKey.Enter);

                        pwdScore = PasswordAdvisor.CheckStrength(pass);

                        if (pwdScore == PasswordAdvisor.PasswordScore.Blank)
                        {
                            Console.Clear();
                            PrintHeader();
                            DefaultMessages.PrintErrorMessage("Password can not be blank!!! Please insert password.");
                        }
                        else
                        {
                            if (i == 0)
                            {
                                pass1 = pass;
                            }
                            else
                            {
                                pass2 = pass;
                            }


                            break;
                        }
                    }
                }

                if (pass1 != pass2)
                {
                    Console.Clear();
                    PrintHeader();
                    DefaultMessages.PrintErrorMessage("Password and confirmation do not match!!!");
                }
                else
                {
                    user.Password = "******";
                    pwdScore      = PasswordAdvisor.CheckStrength(pass1);

                    if (pwdScore == PasswordAdvisor.PasswordScore.VeryWeak)
                    {
                        Console.Clear();
                        PrintHeader();
                        DefaultMessages.PrintWarningMessage("Inserted password is weak");
                        if (WantToContinue())
                        {
                            Console.Clear();
                            PrintHeader();
                            break;
                        }
                        else
                        {
                            user.Password = "";
                            Console.Clear();
                            PrintHeader();
                        }
                    }
                }
            }
        }