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

@@ -44,6 +44,8 @@ public class AppConfiguration
public string? AuthorizationEndpoint { get; set; } public string? AuthorizationEndpoint { get; set; }
public string? AccessEndpoint { get; set; } public string? AccessEndpoint { get; set; }
public string? AuthorizationRedirect { get; set; } public string? AuthorizationRedirect { get; set; }
public bool FirstUserAdmin { get; set; } = true;
} }
} }

View File

@@ -278,9 +278,18 @@ public class OAuth2Controller : Controller
{ {
Username = username, Username = username,
Email = email, 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); return await UserRepository.Add(user);
} }