mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-03-10 12:05:51 -04:00
Co-authored-by: Joseph Milazzo <joseph.v.milazzo@gmail.com> Co-authored-by: Joe Milazzo <josephmajora@gmail.com>
30 lines
826 B
C#
30 lines
826 B
C#
using System.Threading.Tasks;
|
|
using Kavita.API.Attributes;
|
|
using Kavita.Models.Constants;
|
|
using Kavita.Models.Entities.User;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Kavita.Server.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;
|
|
}
|
|
|
|
|
|
}
|