Add remaining project files
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user