Skip to content

Commit

Permalink
Updated CurrentUserProviderWeb with real implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix-CodingClimber committed Sep 9, 2024
1 parent d8423da commit 58f6db4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/DotNetElements.Web.AspNetCore/CurrentUserProviderWeb.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using System.Security.Claims;
using Microsoft.AspNetCore.Http;

namespace DotNetElements.Web.AspNetCore;

Expand All @@ -11,9 +12,14 @@ public CurrentUserProviderWeb(IHttpContextAccessor contextAccessor)
this.contextAccessor = contextAccessor;
}

// todo
public Guid GetCurrentUserId()
{
return new Guid("e8d118e0-18c6-4fff-9d86-e91a915d8198");
string? userId = contextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier);

// todo better error handling
if (userId is null)
throw new ArgumentNullException(nameof(userId));

return new Guid(userId);
}
}

0 comments on commit 58f6db4

Please sign in to comment.