refactor(ProfileController): Aktualisierung, um JWT zum Abrufen der Benutzer-ID anstelle der Abfragezeichenfolge zu verwenden
This commit is contained in:
parent
dd2dbee037
commit
a378862791
@ -24,11 +24,17 @@ public class ProfileController : ControllerBase
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAsync([FromQuery] ReadProfile profileQ)
|
||||
public async Task<IActionResult> GetAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var profile = await _mediator.Send(profileQ);
|
||||
if (!this.TryGetUserId(out var userId))
|
||||
{
|
||||
_logger.LogError("Invalid user ID: Retrieved ID is null or not an integer.");
|
||||
return Unauthorized("Failed to retrieve user identity.");
|
||||
}
|
||||
|
||||
var profile = await _mediator.Send(new ReadProfile(UserId: userId ?? throw new InvalidOperationException("User ID is null")));
|
||||
return profile is null ? NotFound() : Ok(profile);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user