fix not being able to delete discord auth for not finished reg account

This commit is contained in:
Stanley Dimant
2022-08-03 01:20:31 +02:00
parent b0ec2c5001
commit 2a902ef15f

View File

@@ -96,11 +96,16 @@ namespace MareSynchronosServer.Discord
using var scope = services.CreateScope();
using var db = scope.ServiceProvider.GetService<MareDbContext>();
var discordAuthedUser = await db.LodeStoneAuth.Include(u => u.User).FirstOrDefaultAsync(u => u.DiscordId == id);
if (discordAuthedUser != null && discordAuthedUser.User != null)
if (discordAuthedUser != null)
{
logger.LogInformation("Purging user: " + discordAuthedUser.User.UID);
FileCleanupService.PurgeUser(discordAuthedUser.User, db, configuration);
if (discordAuthedUser.User != null)
{
FileCleanupService.PurgeUser(discordAuthedUser.User, db, configuration);
}
else
{
db.Remove(discordAuthedUser);
}
await db.SaveChangesAsync();
}