Implemented First User Admin Feature

This commit is contained in:
mxritzdev
2025-05-17 17:53:05 +02:00
parent 9dc77e6dde
commit 7ead76fbcc
2 changed files with 13 additions and 2 deletions

View File

@@ -273,13 +273,22 @@ public class OAuth2Controller : Controller
if (await UserRepository.Get().AnyAsync(x => x.Email == email))
throw new HttpApiException("A account with that email already exists", 400);
var user = new User()
{
Username = username,
Email = email,
Password = HashHelper.Hash(password)
Password = HashHelper.Hash(password),
};
if (Configuration.Authentication.OAuth2.FirstUserAdmin)
{
var userCount = await UserRepository.Get().CountAsync();
if (userCount == 0)
user.PermissionsJson = "[\"*\"]";
}
return await UserRepository.Add(user);
}