24 lines
812 B
C#
24 lines
812 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using khmer_eid_backend.Integrations.Ory;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using System.Security.Claims;
|
|
|
|
namespace khmer_eid_backend.Controllers;
|
|
|
|
public class UserController(KratosIntegration _kratos) : ControllerBase
|
|
{
|
|
[HttpGet("me")]
|
|
[Authorize(AuthenticationSchemes = "Kratos")]
|
|
// public Task<IActionResult> Me()
|
|
// {
|
|
// var id = User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
// var phone = User.FindFirstValue("phone");
|
|
// // return Ok(new { id, phone });
|
|
// return Task.FromResult<IActionResult>(Ok(new { id, phone }));
|
|
// }
|
|
public async Task<IActionResult> Me()
|
|
{
|
|
var data = await _kratos.GetMe(Request.Headers.Authorization.ToString().Replace("Bearer ",""));
|
|
return Ok(data);
|
|
}
|
|
} |