diff --git a/ProjectLighthouse/Administration/Maintenance/Commands/DeleteUserCommand.cs b/ProjectLighthouse/Administration/Maintenance/Commands/DeleteUserCommand.cs index cb783dcc..f61b2bf9 100644 --- a/ProjectLighthouse/Administration/Maintenance/Commands/DeleteUserCommand.cs +++ b/ProjectLighthouse/Administration/Maintenance/Commands/DeleteUserCommand.cs @@ -20,7 +20,7 @@ public class DeleteUserCommand : ICommand public int RequiredArgs() => 1; public async Task Run(string[] args, Logger logger) { - User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username == args[0]); + User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username.Length > 0 && u.Username == args[0]); if (user == null) try { diff --git a/ProjectLighthouse/Database.cs b/ProjectLighthouse/Database.cs index 782e4c72..ee00fdc7 100644 --- a/ProjectLighthouse/Database.cs +++ b/ProjectLighthouse/Database.cs @@ -476,6 +476,7 @@ public class Database : DbContext public async Task RemoveUser(User? user) { if (user == null) return; + if (user.Username.Length == 0) return; // don't delete the placeholder user if (user.Location != null) this.Locations.Remove(user.Location); LastContact? lastContact = await this.LastContacts.FirstOrDefaultAsync(l => l.UserId == user.UserId);