From a3788627914d0d431c1c0a0fa6983994fd5bcf7b Mon Sep 17 00:00:00 2001 From: TekH Date: Thu, 24 Jul 2025 17:53:31 +0200 Subject: [PATCH] refactor(ProfileController): Aktualisierung, um JWT zum Abrufen der Benutzer-ID anstelle der Abfragezeichenfolge zu verwenden --- src/WorkFlow.API/Controllers/ProfileController.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/WorkFlow.API/Controllers/ProfileController.cs b/src/WorkFlow.API/Controllers/ProfileController.cs index f4cbdce..4f2fdbd 100644 --- a/src/WorkFlow.API/Controllers/ProfileController.cs +++ b/src/WorkFlow.API/Controllers/ProfileController.cs @@ -24,11 +24,17 @@ public class ProfileController : ControllerBase } [HttpGet] - public async Task GetAsync([FromQuery] ReadProfile profileQ) + public async Task 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)