C
C#3d ago
Ellopis

✅ Using Identity with bearer. How do I retrieve the user, or userId in a request?

When doing a request I'm doing
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var blogs = context.Blogs.where(b => userId == b.UserId);
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var blogs = context.Blogs.where(b => userId == b.UserId);
Is this the way of doing it?
2 Replies
this_is_pain
this_is_pain3d ago
without knowing anything about the software you're working on it seems ok to me i guess that's a context where user must be authenticated
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View

Did you find this page helpful?