mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-13 23:44:15 +01:00
actually purge users on deletion
This commit is contained in:
parent
915152bae9
commit
f794d62122
2 changed files with 47 additions and 43 deletions
|
|
@ -78,9 +78,10 @@ namespace MareSynchronosServer.Discord
|
||||||
var discordAuthedUser = await db.LodeStoneAuth.Include(u => u.User).FirstOrDefaultAsync(u => u.DiscordId == id);
|
var discordAuthedUser = await db.LodeStoneAuth.Include(u => u.User).FirstOrDefaultAsync(u => u.DiscordId == id);
|
||||||
if (discordAuthedUser != null && discordAuthedUser.User != null)
|
if (discordAuthedUser != null && discordAuthedUser.User != null)
|
||||||
{
|
{
|
||||||
logger.LogInformation("User will be purged on next round of deletions: " + discordAuthedUser.User);
|
logger.LogInformation("Purging user: " + discordAuthedUser.User.UID);
|
||||||
discordAuthedUser.User.LastLoggedIn = new DateTime(1900, 1, 1).ToUniversalTime();
|
|
||||||
db.Remove(discordAuthedUser);
|
FileCleanupService.PurgeUser(discordAuthedUser.User, db, configuration);
|
||||||
|
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -180,8 +181,6 @@ namespace MareSynchronosServer.Discord
|
||||||
{
|
{
|
||||||
embedBuilder.WithTitle("Failed to verify your character");
|
embedBuilder.WithTitle("Failed to verify your character");
|
||||||
embedBuilder.WithDescription("Did not find requested authentication key on your profile. Make sure you have saved *twice*, then do **/verify** again.");
|
embedBuilder.WithDescription("Did not find requested authentication key on your profile. Make sure you have saved *twice*, then do **/verify** again.");
|
||||||
DiscordLodestoneMapping.TryRemove(id, out _);
|
|
||||||
db.Remove(lodestoneAuth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,21 @@ namespace MareSynchronosServer
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var user in usersToRemove)
|
foreach (var user in usersToRemove)
|
||||||
|
{
|
||||||
|
PurgeUser(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation($"Cleanup complete");
|
||||||
|
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PurgeUser(User user, MareDbContext dbContext, IConfiguration _configuration)
|
||||||
{
|
{
|
||||||
var lodestone = dbContext.LodeStoneAuth.SingleOrDefault(a => a.User.UID == user.UID);
|
var lodestone = dbContext.LodeStoneAuth.SingleOrDefault(a => a.User.UID == user.UID);
|
||||||
|
|
||||||
|
|
@ -153,16 +168,6 @@ namespace MareSynchronosServer
|
||||||
dbContext.Remove(auth);
|
dbContext.Remove(auth);
|
||||||
dbContext.Remove(user);
|
dbContext.Remove(user);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_logger.LogInformation($"Cleanup complete");
|
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task StopAsync(CancellationToken cancellationToken)
|
public Task StopAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue