37 lines
1010 B
C#
37 lines
1010 B
C#
using DeluxeBackend.Models;
|
|
using DeluxeBackend.Services;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace DeluxeBackend.Controllers.Auth
|
|
{
|
|
[Route("Auth/role")]
|
|
[ApiController]
|
|
public class RoleController : ControllerBase
|
|
{
|
|
|
|
private readonly ILiteDbService db;
|
|
private readonly IJwtService jwt;
|
|
private readonly DiscordBotService discord;
|
|
public RoleController(ILiteDbService _db, IJwtService _jwtService, DiscordBotService discordBotService)
|
|
{
|
|
db = _db;
|
|
jwt = _jwtService;
|
|
discord = discordBotService;
|
|
}
|
|
|
|
[HttpGet("{roleName}/{accId}")]
|
|
public async Task<IActionResult> HasRole(string roleName, long accId)
|
|
{
|
|
Account? account = db.Accounts.FindById(accId);
|
|
|
|
if (account == null)
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
return Ok(await account.HasRoleAsync(discord, roleName));
|
|
}
|
|
}
|
|
}
|