mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-07-09 03:04:19 -04:00
adding admin exists api
This commit is contained in:
parent
8156aeb495
commit
f8d7581a12
24
API/Controllers/AdminController.cs
Normal file
24
API/Controllers/AdminController.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System.Threading.Tasks;
|
||||
using API.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace API.Controllers
|
||||
{
|
||||
public class AdminController : BaseApiController
|
||||
{
|
||||
private readonly IUserRepository _userRepository;
|
||||
|
||||
public AdminController(IUserRepository userRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<bool>> AdminExists()
|
||||
{
|
||||
return await _userRepository.AdminExists();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -62,5 +62,11 @@ namespace API.Data
|
||||
.ProjectTo<MemberDto>(_mapper.ConfigurationProvider)
|
||||
.SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> AdminExists()
|
||||
{
|
||||
return await _context.Users.AnyAsync(x => x.IsAdmin);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -15,5 +15,6 @@ namespace API.Interfaces
|
||||
Task<AppUser> GetUserByUsernameAsync(string username);
|
||||
Task<IEnumerable<MemberDto>> GetMembersAsync();
|
||||
Task<MemberDto> GetMemberAsync(string username);
|
||||
Task<bool> AdminExists();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user