mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-12 04:52:26 +00:00
Don't issue registration tokens for names that already exist
This commit is contained in:
parent
75de1d0faa
commit
e67abe0164
2 changed files with 21 additions and 5 deletions
|
@ -83,6 +83,12 @@ public class UserEndpoints : ApiEndpointController
|
|||
APIKey? apiKey = await this.database.APIKeys.FirstOrDefaultAsync(k => k.Key == authToken);
|
||||
if (apiKey == null) return this.StatusCode(403, null);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(username))
|
||||
{
|
||||
bool userExists = await this.database.Users.AnyAsync(u => u.Username == username);
|
||||
if (userExists) return this.BadRequest();
|
||||
}
|
||||
|
||||
RegistrationToken token = new()
|
||||
{
|
||||
Created = DateTime.Now,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue