Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void zalogujProfil()
- {
- string log;
- string pass;
- try
- {
- User us=new User();
- Console.CursorVisible = false;
- Console.SetCursorPosition(0, 0);
- Console.WriteLine("______________________", Color.DarkCyan);
- Console.SetCursorPosition(0, 2);
- Console.WriteLine("LOGOWANIE UŻYTKOWNIKA");
- Console.SetCursorPosition(0, 3);
- Console.WriteLine("______________________", Color.DarkCyan);
- Console.SetCursorPosition(0, 6);
- StreamReader loadFileUser = new StreamReader("Profile.txt");
- string line;
- while ((line = loadFileUser.ReadLine()) != null)
- {
- User load1 = JsonConvert.DeserializeObject<User>(line);
- Console.Write("Login: ");
- log = Console.ReadLine();
- if (log.Length <= 0 || log!=load1.login)
- {
- do
- {
- Console.WriteLine("Login nieprawidlowy");
- Console.Write("Login: ");
- log = Console.ReadLine();
- } while (log.Length <= 0 || log != load1.login);
- }
- Console.Write("Hasło: ");
- pass = "";
- ConsoleKeyInfo keyInfo;
- do
- {
- keyInfo = Console.ReadKey(true);
- // Skip if Backspace or Enter is Pressed
- if (keyInfo.Key != ConsoleKey.Backspace && keyInfo.Key != ConsoleKey.Enter)
- {
- pass += keyInfo.KeyChar;
- Console.Write("*");
- }
- else
- {
- if (keyInfo.Key == ConsoleKey.Backspace && pass.Length > 0)
- {
- // Remove last charcter if Backspace is Pressed
- pass = pass.Substring(0, (pass.Length - 1));
- Console.Write("\b \b");
- }
- }
- }
- // Stops Getting Password Once Enter is Pressed
- while (keyInfo.Key != ConsoleKey.Enter);
- if ( load1.haslo!=pass || pass.Length <= 0)
- {
- do
- {
- Console.WriteLine("\nHaslo nieprawidlowe.");
- Console.Write("Hasło: ");
- pass = "";
- do
- {
- keyInfo = Console.ReadKey(true);
- if (keyInfo.Key != ConsoleKey.Backspace && keyInfo.Key != ConsoleKey.Enter)
- {
- pass += keyInfo.KeyChar;
- Console.Write("*");
- }
- else
- {
- if (keyInfo.Key == ConsoleKey.Backspace && pass.Length > 0)
- {
- pass = pass.Substring(0, (pass.Length - 1));
- Console.Write("\b \b");
- }
- }
- }
- while (keyInfo.Key != ConsoleKey.Enter);
- } while (load1.haslo != pass || pass.Length <= 0);
- }
- foreach (User use in profileList)
- {
- if (use.login == log && use.haslo==pass)
- {
- this.imie = use.imie;
- this.nazwisko = use.nazwisko;
- this.waga = use.waga;
- this.wzrost = use.wzrost;
- this.dataUr = use.dataUr;
- this.wiek = use.wiek;
- this.aktywnosc = use.aktywnosc;
- this.login = use.login;
- this.plec = use.plec;
- this.haslo = use.haslo;
- this.BMI = use.BMI;
- this.kg = use.kg;
- this.CPM = use.CPM;
- this.newCPM = use.newCPM;
- }
- }
- Console.SetCursorPosition(0, 16);
- loadFileUser.Close();
- break;
- }
- }
- catch (FormatException)
- {
- Console.WriteLine("Wprowadziles zle dane");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement