add hashed key to log

This commit is contained in:
Stanley Dimant
2024-08-11 15:06:33 +02:00
parent 30f003828e
commit a159a2ac71
2 changed files with 8 additions and 4 deletions

View File

@@ -59,9 +59,10 @@ public partial class MareWizardModule
} }
computedHash = StringUtils.Sha256String(StringUtils.GenerateRandomString(64) + DateTime.UtcNow.ToString()); computedHash = StringUtils.Sha256String(StringUtils.GenerateRandomString(64) + DateTime.UtcNow.ToString());
string hashedKey = StringUtils.Sha256String(computedHash);
auth = new Auth() auth = new Auth()
{ {
HashedKey = StringUtils.Sha256String(computedHash), HashedKey = hashedKey,
User = previousAuth.User, User = previousAuth.User,
PrimaryUserUID = previousAuth.PrimaryUserUID PrimaryUserUID = previousAuth.PrimaryUserUID
}; };
@@ -77,5 +78,7 @@ public partial class MareWizardModule
await db.Auth.AddAsync(auth).ConfigureAwait(false); await db.Auth.AddAsync(auth).ConfigureAwait(false);
await db.SaveChangesAsync().ConfigureAwait(false); await db.SaveChangesAsync().ConfigureAwait(false);
_botServices.Logger.LogInformation("User recovered: {userUID}:{hashedKey}", previousAuth.UserUID, hashedKey);
} }
} }

View File

@@ -261,23 +261,24 @@ public partial class MareWizardModule
user.LastLoggedIn = DateTime.UtcNow; user.LastLoggedIn = DateTime.UtcNow;
var computedHash = StringUtils.Sha256String(StringUtils.GenerateRandomString(64) + DateTime.UtcNow.ToString()); var computedHash = StringUtils.Sha256String(StringUtils.GenerateRandomString(64) + DateTime.UtcNow.ToString());
string hashedKey = StringUtils.Sha256String(computedHash);
var auth = new Auth() var auth = new Auth()
{ {
HashedKey = StringUtils.Sha256String(computedHash), HashedKey = hashedKey,
User = user, User = user,
}; };
await db.Users.AddAsync(user).ConfigureAwait(false); await db.Users.AddAsync(user).ConfigureAwait(false);
await db.Auth.AddAsync(auth).ConfigureAwait(false); await db.Auth.AddAsync(auth).ConfigureAwait(false);
_botServices.Logger.LogInformation("User registered: {userUID}", user.UID);
lodestoneAuth.StartedAt = null; lodestoneAuth.StartedAt = null;
lodestoneAuth.User = user; lodestoneAuth.User = user;
lodestoneAuth.LodestoneAuthString = null; lodestoneAuth.LodestoneAuthString = null;
await db.SaveChangesAsync().ConfigureAwait(false); await db.SaveChangesAsync().ConfigureAwait(false);
_botServices.Logger.LogInformation("User registered: {userUID}:{hashedKey}", user.UID, hashedKey);
_botServices.DiscordVerifiedUsers.Remove(Context.User.Id, out _); _botServices.DiscordVerifiedUsers.Remove(Context.User.Id, out _);
return (user.UID, computedHash); return (user.UID, computedHash);