add datetime string to initial auth hash, add logging for discord commands, add file logger
This commit is contained in:
@@ -138,6 +138,7 @@ namespace MareSynchronosServices
|
|||||||
var otherPairData = dbContext.ClientPairs.Include(u => u.User)
|
var otherPairData = dbContext.ClientPairs.Include(u => u.User)
|
||||||
.Where(u => u.OtherUser.UID == user.UID).ToList();
|
.Where(u => u.OtherUser.UID == user.UID).ToList();
|
||||||
|
|
||||||
|
_logger.LogInformation("User purged: {uid}", user.UID);
|
||||||
|
|
||||||
metrics.DecGauge(MetricsAPI.GaugePairs, ownPairData.Count + otherPairData.Count);
|
metrics.DecGauge(MetricsAPI.GaugePairs, ownPairData.Count + otherPairData.Count);
|
||||||
metrics.DecGauge(MetricsAPI.GaugePairsPaused, ownPairData.Count + ownPairData.Count(c => c.IsPaused));
|
metrics.DecGauge(MetricsAPI.GaugePairsPaused, ownPairData.Count + ownPairData.Count(c => c.IsPaused));
|
||||||
|
|||||||
@@ -71,8 +71,11 @@ public class DiscordBot : IHostedService
|
|||||||
{
|
{
|
||||||
if (arg.Data.Name == "register")
|
if (arg.Data.Name == "register")
|
||||||
{
|
{
|
||||||
|
logger.LogInformation("{user} called register", arg.User.Id);
|
||||||
|
|
||||||
if (arg.Data.Options.FirstOrDefault(f => f.Name == "overwrite_old_account") != null)
|
if (arg.Data.Options.FirstOrDefault(f => f.Name == "overwrite_old_account") != null)
|
||||||
{
|
{
|
||||||
|
logger.LogInformation("{user} called register with overwrite_old_account", arg.User.Id);
|
||||||
await DeletePreviousUserAccount(arg.User.Id).ConfigureAwait(false);
|
await DeletePreviousUserAccount(arg.User.Id).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +87,7 @@ public class DiscordBot : IHostedService
|
|||||||
}
|
}
|
||||||
else if (arg.Data.Name == "verify")
|
else if (arg.Data.Name == "verify")
|
||||||
{
|
{
|
||||||
|
logger.LogInformation("{user} called verify", arg.User.Id);
|
||||||
EmbedBuilder eb = new();
|
EmbedBuilder eb = new();
|
||||||
if (verificationQueue.Any(u => u.User.Id == arg.User.Id))
|
if (verificationQueue.Any(u => u.User.Id == arg.User.Id))
|
||||||
{
|
{
|
||||||
@@ -105,6 +109,8 @@ public class DiscordBot : IHostedService
|
|||||||
}
|
}
|
||||||
else if (arg.Data.Name == "setvanityuid")
|
else if (arg.Data.Name == "setvanityuid")
|
||||||
{
|
{
|
||||||
|
logger.LogInformation("{user} called setvanityuid", arg.User.Id);
|
||||||
|
|
||||||
EmbedBuilder eb = new();
|
EmbedBuilder eb = new();
|
||||||
var newUid = (string)arg.Data.Options.First(f => f.Name == "vanity_uid").Value;
|
var newUid = (string)arg.Data.Options.First(f => f.Name == "vanity_uid").Value;
|
||||||
eb = await HandleVanityUid(eb, arg.User.Id, newUid);
|
eb = await HandleVanityUid(eb, arg.User.Id, newUid);
|
||||||
@@ -247,7 +253,7 @@ public class DiscordBot : IHostedService
|
|||||||
user.LastLoggedIn = DateTime.UtcNow - TimeSpan.FromDays(purgedDays) + TimeSpan.FromDays(1);
|
user.LastLoggedIn = DateTime.UtcNow - TimeSpan.FromDays(purgedDays) + TimeSpan.FromDays(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var computedHash = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(GenerateRandomString(64)))).Replace("-", "");
|
var computedHash = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(GenerateRandomString(64) + DateTime.UtcNow.ToString()))).Replace("-", "");
|
||||||
var auth = new Auth()
|
var auth = new Auth()
|
||||||
{
|
{
|
||||||
HashedKey = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(computedHash)))
|
HashedKey = BitConverter.ToString(sha256.ComputeHash(Encoding.UTF8.GetBytes(computedHash)))
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
<PackageReference Include="Discord.Net" Version="3.7.2" />
|
<PackageReference Include="Discord.Net" Version="3.7.2" />
|
||||||
<PackageReference Include="EFCore.NamingConventions" Version="6.0.0" />
|
<PackageReference Include="EFCore.NamingConventions" Version="6.0.0" />
|
||||||
<PackageReference Include="Grpc.AspNetCore" Version="2.47.0" />
|
<PackageReference Include="Grpc.AspNetCore" Version="2.47.0" />
|
||||||
|
<PackageReference Include="Karambolo.Extensions.Logging.File" Version="3.3.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.8" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.8" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="6.0.0" />
|
||||||
<PackageReference Include="prometheus-net.AspNetCore" Version="6.0.0" />
|
<PackageReference Include="prometheus-net.AspNetCore" Version="6.0.0" />
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using MareSynchronosShared.Metrics;
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@@ -33,6 +34,11 @@ public class Program
|
|||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
||||||
|
webBuilder.ConfigureLogging((ctx, builder) =>
|
||||||
|
{
|
||||||
|
builder.AddConfiguration(ctx.Configuration.GetSection("Logging"));
|
||||||
|
builder.AddFile(o => o.RootPath = AppContext.BaseDirectory);
|
||||||
|
});
|
||||||
webBuilder.UseStartup<Startup>();
|
webBuilder.UseStartup<Startup>();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user