Fix bug when trying to create users

This commit is contained in:
Slendy 2023-07-09 11:52:32 -05:00
parent 25bb2ecfc1
commit 1b170081eb
No known key found for this signature in database
GPG key ID: 7288D68361B91428
2 changed files with 4 additions and 3 deletions

View file

@ -33,7 +33,7 @@ public class CreateUserCommand : ICommand
password = CryptoHelper.Sha256Hash(password);
UserEntity? user = await database.Users.FirstOrDefaultAsync(u => u.Username == onlineId);
if (user == null)
if (user != null)
{
logger.LogError("A user with this username already exists.", LogArea.Command);
return;

View file

@ -5,6 +5,7 @@ using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Logging;
using LBPUnion.ProjectLighthouse.Types.Maintenance;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
@ -32,7 +33,7 @@ public class WipeTokensForUserCommand : ICommand
user = await database.Users.FirstOrDefaultAsync(u => u.UserId == userId);
if (user == null)
{
Console.WriteLine(@$"Could not find user by parameter '{args[0]}'");
logger.LogError(@$"Could not find user by parameter '{args[0]}'", LogArea.Command);
return;
}
}
@ -40,6 +41,6 @@ public class WipeTokensForUserCommand : ICommand
await database.GameTokens.RemoveWhere(t => t.UserId == user.UserId);
await database.WebTokens.RemoveWhere(t => t.UserId == user.UserId);
Console.WriteLine(@$"Deleted all tokens for {user.Username} (id: {user.UserId}).");
logger.LogSuccess(@$"Deleted all tokens for {user.Username} (id: {user.UserId}).", LogArea.Command);
}
}