Browse Source

fix: fix bug auth

klmnvan 5 months ago
parent
commit
25435088f7
2 changed files with 13 additions and 10 deletions
  1. 12 9
      HelloItQuantum/Function/WorkWithFile.cs
  2. 1 1
      HelloItQuantum/ViewModels/AuthViewModel.cs

+ 12 - 9
HelloItQuantum/Function/WorkWithFile.cs

@@ -25,17 +25,20 @@ namespace HelloItQuantum.Function
 			List<User> users = new List<User>();
 			using (StreamReader read = new StreamReader(filePath))
 			{
-				while (!read.EndOfStream)
+                while (!read.EndOfStream)
 				{
 					string[] row = read.ReadLine().Split(';');
-					User user = new User();
-					user.Nickname = row[0];
-					user.Name = row[1];
-					user.Surname = row[2];
-					user.GameHotkeys = Convert.ToInt32(row[3]);
-					user.GameCreateFriend = Convert.ToInt32(row[4]);
-					user.GameLabyrinth = Convert.ToInt32(row[5]);
-					users.Add(user);
+					if (row.Length == 6)
+					{
+                        User user = new User();
+                        user.Nickname = row[0];
+                        user.Name = row[1];
+                        user.Surname = row[2];
+                        user.GameHotkeys = Convert.ToInt32(row[3]);
+                        user.GameCreateFriend = Convert.ToInt32(row[4]);
+                        user.GameLabyrinth = Convert.ToInt32(row[5]);
+                        users.Add(user);
+                    }
 				}
 			}
 			return users;

+ 1 - 1
HelloItQuantum/ViewModels/AuthViewModel.cs

@@ -23,7 +23,7 @@ namespace HelloItQuantum.ViewModels
         public void Auth()
         {
             List<User>? users = WorkWithFile.GetAllUsers();
-            if(users.Count != 0)
+            if(users != null)
             {
                 userNicknames = users.Select(it => it.Nickname).ToList();
                 if (userNicknames.Contains(Nickname))