mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-12-16 10:05:05 -05:00
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com> Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
30 lines
784 B
C#
30 lines
784 B
C#
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<AppUser> userManager) : BaseApiController
|
|
{
|
|
/// <summary>
|
|
/// Checks if an admin exists on the system. This is essentially a check to validate if the system has been set up.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[AllowAnonymous]
|
|
[SkipDeviceTracking]
|
|
[HttpGet("exists")]
|
|
public async Task<ActionResult<bool>> AdminExists()
|
|
{
|
|
var users = await userManager.GetUsersInRoleAsync(PolicyConstants.AdminRole);
|
|
return users.Count > 0;
|
|
}
|
|
|
|
|
|
}
|