Implemented api/check endpoint. Added api error middleware
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Moonlight.ApiServer.Attributes;
|
||||
using Moonlight.ApiServer.Helpers.Authentication;
|
||||
using Moonlight.ApiServer.Services;
|
||||
using Moonlight.Shared.Http.Requests.Auth;
|
||||
using Moonlight.Shared.Http.Responses.Auth;
|
||||
@@ -41,4 +43,19 @@ public class AuthController : Controller
|
||||
Token = await AuthService.GenerateToken(user)
|
||||
};
|
||||
}
|
||||
|
||||
[HttpGet("check")]
|
||||
[RequirePermission("meta.authenticated")]
|
||||
public async Task<CheckResponse> Check()
|
||||
{
|
||||
var perm = HttpContext.User as PermClaimsPrinciple;
|
||||
var user = perm!.CurrentModel;
|
||||
|
||||
return new CheckResponse()
|
||||
{
|
||||
Email = user.Email,
|
||||
Username = user.Username,
|
||||
Permissions = perm.Permissions
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user