Parcourir la source

fix: fix bug auth

klmnvan il y a 4 mois
Parent
commit
25435088f7

+ 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))