From a159a2ac714ccb83b248c221a1f584a1f9346d8d Mon Sep 17 00:00:00 2001 From: Stanley Dimant Date: Sun, 11 Aug 2024 15:06:33 +0200 Subject: [PATCH] add hashed key to log --- .../Discord/MareWizardModule.Recover.cs | 5 ++++- .../Discord/MareWizardModule.Register.cs | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/MareSynchronosServer/MareSynchronosServices/Discord/MareWizardModule.Recover.cs b/MareSynchronosServer/MareSynchronosServices/Discord/MareWizardModule.Recover.cs index fe30cd4..60cabb2 100644 --- a/MareSynchronosServer/MareSynchronosServices/Discord/MareWizardModule.Recover.cs +++ b/MareSynchronosServer/MareSynchronosServices/Discord/MareWizardModule.Recover.cs @@ -59,9 +59,10 @@ public partial class MareWizardModule } computedHash = StringUtils.Sha256String(StringUtils.GenerateRandomString(64) + DateTime.UtcNow.ToString()); + string hashedKey = StringUtils.Sha256String(computedHash); auth = new Auth() { - HashedKey = StringUtils.Sha256String(computedHash), + HashedKey = hashedKey, User = previousAuth.User, PrimaryUserUID = previousAuth.PrimaryUserUID }; @@ -77,5 +78,7 @@ public partial class MareWizardModule await db.Auth.AddAsync(auth).ConfigureAwait(false); await db.SaveChangesAsync().ConfigureAwait(false); + + _botServices.Logger.LogInformation("User recovered: {userUID}:{hashedKey}", previousAuth.UserUID, hashedKey); } } diff --git a/MareSynchronosServer/MareSynchronosServices/Discord/MareWizardModule.Register.cs b/MareSynchronosServer/MareSynchronosServices/Discord/MareWizardModule.Register.cs index e505e4a..2949adf 100644 --- a/MareSynchronosServer/MareSynchronosServices/Discord/MareWizardModule.Register.cs +++ b/MareSynchronosServer/MareSynchronosServices/Discord/MareWizardModule.Register.cs @@ -261,23 +261,24 @@ public partial class MareWizardModule user.LastLoggedIn = DateTime.UtcNow; var computedHash = StringUtils.Sha256String(StringUtils.GenerateRandomString(64) + DateTime.UtcNow.ToString()); + string hashedKey = StringUtils.Sha256String(computedHash); var auth = new Auth() { - HashedKey = StringUtils.Sha256String(computedHash), + HashedKey = hashedKey, User = user, }; await db.Users.AddAsync(user).ConfigureAwait(false); await db.Auth.AddAsync(auth).ConfigureAwait(false); - _botServices.Logger.LogInformation("User registered: {userUID}", user.UID); - lodestoneAuth.StartedAt = null; lodestoneAuth.User = user; lodestoneAuth.LodestoneAuthString = null; await db.SaveChangesAsync().ConfigureAwait(false); + _botServices.Logger.LogInformation("User registered: {userUID}:{hashedKey}", user.UID, hashedKey); + _botServices.DiscordVerifiedUsers.Remove(Context.User.Id, out _); return (user.UID, computedHash);