private void CreateUsers() { userRoles = new List <UserRole>() { new UserRole() { UserName = "******", Password = AesOperation.EncryptString(key, "Donedeal"), Position = Role.Admin }, new UserRole() { UserName = "******", Password = AesOperation.EncryptString(key, "Freshprince"), Position = Role.Manager }, new UserRole() { UserName = "******", Password = AesOperation.EncryptString(key, "Southpark"), Position = Role.Employee }, new UserRole() { UserName = "******", Password = AesOperation.EncryptString(key, "Evilinc"), Position = Role.Admin } }; }//Creates List of users and roles
}//Creates List of users and roles public void Login() { int tries = 5; CreateUsers(); for (int i = 0; i < 5; i++) { Console.WriteLine("--USER LOGIN--\n"); Console.Write("Username: "******"Password: "******""; do { ConsoleKeyInfo key = Console.ReadKey(true); // Backspace Should Not Work if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter) { password += key.KeyChar; Console.Write("*"); } else { if (key.Key == ConsoleKey.Backspace && password.Length > 0) { password = password.Substring(0, (password.Length - 1)); Console.Write("\b \b"); } else if (key.Key == ConsoleKey.Enter) { break; } } } while (true); //Password Masker string temp = AesOperation.EncryptString(key, password); foreach (UserRole u in userRoles) { if (user == u.UserName && temp == u.Password) { Console.Clear(); password = null; temp = null; CreateData(); Menu(); } } Console.Clear(); tries -= 1; Console.WriteLine("Invalid login please try again ({0} tries left)\n", tries); } Console.Write("Credentials entered incorrectly too many times. Press Enter to exit."); }//Login Screen