using System.Threading.Tasks; using API.Constants; using API.Entities; using API.Middleware; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; namespace API.Controllers; #nullable enable public class AdminController(UserManager userManager) : BaseApiController { /// /// Checks if an admin exists on the system. This is essentially a check to validate if the system has been set up. /// /// [AllowAnonymous] [SkipDeviceTracking] [HttpGet("exists")] public async Task> AdminExists() { var users = await userManager.GetUsersInRoleAsync(PolicyConstants.AdminRole); return users.Count > 0; } }