mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-02 01:58:40 +00:00
Prevent deletion of dev slot placeholder user
This commit is contained in:
parent
643b00512a
commit
976d494e04
2 changed files with 2 additions and 1 deletions
|
@ -20,7 +20,7 @@ public class DeleteUserCommand : ICommand
|
||||||
public int RequiredArgs() => 1;
|
public int RequiredArgs() => 1;
|
||||||
public async Task Run(string[] args, Logger logger)
|
public async Task Run(string[] args, Logger logger)
|
||||||
{
|
{
|
||||||
User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username == args[0]);
|
User? user = await this.database.Users.FirstOrDefaultAsync(u => u.Username.Length > 0 && u.Username == args[0]);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -476,6 +476,7 @@ public class Database : DbContext
|
||||||
public async Task RemoveUser(User? user)
|
public async Task RemoveUser(User? user)
|
||||||
{
|
{
|
||||||
if (user == null) return;
|
if (user == null) return;
|
||||||
|
if (user.Username.Length == 0) return; // don't delete the placeholder user
|
||||||
|
|
||||||
if (user.Location != null) this.Locations.Remove(user.Location);
|
if (user.Location != null) this.Locations.Remove(user.Location);
|
||||||
LastContact? lastContact = await this.LastContacts.FirstOrDefaultAsync(l => l.UserId == user.UserId);
|
LastContact? lastContact = await this.LastContacts.FirstOrDefaultAsync(l => l.UserId == user.UserId);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue