Cleanup code

This commit is contained in:
jvyden 2021-12-11 14:33:28 -05:00
parent 1ec7bdf1f6
commit b0b9ad2172
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
58 changed files with 310 additions and 424 deletions

View file

@ -4,8 +4,8 @@ using JetBrains.Annotations;
using Kettu;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
using Microsoft.EntityFrameworkCore;
using LBPUnion.ProjectLighthouse.Types;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
{
@ -24,32 +24,27 @@ namespace LBPUnion.ProjectLighthouse.Maintenance.Commands
User? user = await this._database.Users.FirstOrDefaultAsync(u => u.Username == onlineId);
if (user == null)
{
user = await this._database.CreateUser(onlineId,
HashHelper.BCryptHash(password));
Logger.Log(
$"Created user {user.UserId} with online ID (username) {user.Username} and the specified password.", LoggerLevelLogin.Instance);
user = await this._database.CreateUser(onlineId, HashHelper.BCryptHash(password));
Logger.Log($"Created user {user.UserId} with online ID (username) {user.Username} and the specified password.", LoggerLevelLogin.Instance);
user.PasswordResetRequired = true;
Logger.Log("This user will need to reset their password when they log in.",
LoggerLevelLogin.Instance);
Logger.Log("This user will need to reset their password when they log in.", LoggerLevelLogin.Instance);
await this._database.SaveChangesAsync();
Logger.Log("Database changes saved.",
LoggerLevelDatabase.Instance);
Logger.Log("Database changes saved.", LoggerLevelDatabase.Instance);
}
else
{
Logger.Log("A user with this username already exists.",
LoggerLevelLogin.Instance);
Logger.Log("A user with this username already exists.", LoggerLevelLogin.Instance);
}
}
public string Name() => "Create New User";
public string[] Aliases() =>
new[]
public string[] Aliases()
=> new[]
{
"useradd", "adduser", "newuser", "createUser"
"useradd", "adduser", "newuser", "createUser",
};
public string Arguments() => "<OnlineID> <Password>";