C
C#17mo ago
JUK_Karol

❔ asp.net core auth in endpoint

Hey, I want endpoint that will give null guid to getOffers if user is not auth or if is auth give logged user guid. When I use AllowAnonymous User.Identity.IsAuthenticated is allways null, is there other solution than create one endpoint to get offers for logged user and one for unlogged?
5 Replies
Tinefol
Tinefol17mo ago
The cleanest way would to be to introduce some kind of authentication middleware the one that would let the request through, but indicated that it isn't trully authenticated
JUK_Karol
JUK_KarolOP17mo ago
have u seen it implemented somewhere? is use 2 enpoints in this case (one for logged user and one for unlogged) will be bad practice?
Tinefol
Tinefol17mo ago
yea, two endpoints is pretty dirty, you should go with middleware
Tinefol
Tinefol17mo ago
Customize the behavior of AuthorizationMiddleware
This article explains how to customize the result handling of AuthorizationMiddleware.
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server