public static bool AccountExist(long index, string username) { var db = MySQL.DB_RS; { db.Open("SELECT * FROM accounts WHERE Username='******'", MySQL.DB_CONN, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic); if (db.EOF) { ServerTCP.SendAlertTo(index, "User with this login doesn't exist!"); db.Close(); return(false); } else { db.Close(); return(true); } } }
private static void Packet_CLoginAccount(long index, byte[] data) { ByteBuffer buffer = new ByteBuffer(); buffer.WriteBytes(data); long packetNum = buffer.ReadLong(); string username = buffer.ReadString(); string password = buffer.ReadString(); if (!Database.AccountExist(index, username)) { return; } if (!Database.PasswordOK(index, username, password)) { return; } Program.Log($"Пользователь {username} успешно авторизовался!"); ServerTCP.SendAlertTo(index, "You logged in!"); }
public static bool PasswordOK(long index, string username, string password) { var db = MySQL.DB_RS; { db.Open("SELECT '" + username + "' FROM accounts WHERE Password='******'", MySQL.DB_CONN, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic); if (db.EOF) { ServerTCP.SendAlertTo(index, "Incorrect passord"); db.Close(); return(false); } else { db.Close(); return(true); } } }