public static bool UpdateAccountData(SQLiteConnection connection, string email, string password, int serverId) { var reqStr = $"UPDATE users SET password='******' WHERE email='{email}'"; if (IsAccountExists(connection, email, serverId)) { using (var cmd = new SQLiteCommand(reqStr, connection)) { cmd.ExecuteNonQuery(); return(true); } } return(false); }
public static UserInfo GetLoginAccount(SQLiteConnection connection, string email, string password, int serverId) { var reqStr = $"SELECT * FROM users WHERE server_id='{serverId}' AND email='{email}' " + $"AND password='******'"; if (connection.State == ConnectionState.Open) { using (var cmd = new SQLiteCommand(reqStr, connection)) using (var reader = cmd.ExecuteReader()) { if (reader.Read()) { var user = new UserInfo(); user.Id = reader.GetInt32(0); user.ServerId = reader.GetInt32(3); return(user); } } } return(null); }
public static bool AddAccount(SQLiteConnection connection, string email, string password, int serverId) { string reqStr = $"INSERT into users (email,password,server_id) VALUES ('{email}','{UserSHA1.ComputeHash(password)}','{serverId}')"; if (!IsAccountExists(connection, email, serverId)) { using (var cmd = new SQLiteCommand(reqStr, connection)) { cmd.ExecuteNonQuery(); return(true); } } return(false); }