Get the currently logged in member in an UmbracoApiController?
Hi, I'm struggling a bit with this. I have a member with 2fa enabled (if it matters), I'm able to log in and authenticate. I have an UmbracoApiController that performs some things, but before performing any operation in the api I want to check the currently logged in member. (Member, not User!)
While logged in and authenticated, this does not work:
var member = _membershipHelper.GetCurrentMemberAsync();
_memberShipHelper is an instance of IMemberManager. But in this case the Result of member becomes null. Am I going to have to send an id/email/username as a parameter to my api call just to retrieve the currently logged in member? I want to avoid this.
In fact, this GetCurrentMemberAsync() method works in a razor view, but not in the apicontroller. Why is that?
Yes, this ended up being the correct method after all. The problem was on my end, as I was sending the API calls through Postman, I guess the system doesn't use the session or something like that? When I made the query through the browser, I was able to retrieve the currently logged in member. I am also on Umbraco 10.
Get the currently logged in member in an UmbracoApiController?
Hi, I'm struggling a bit with this. I have a member with 2fa enabled (if it matters), I'm able to log in and authenticate. I have an UmbracoApiController that performs some things, but before performing any operation in the api I want to check the currently logged in member. (Member, not User!)
While logged in and authenticated, this does not work:
_memberShipHelper is an instance of IMemberManager. But in this case the Result of member becomes null. Am I going to have to send an id/email/username as a parameter to my api call just to retrieve the currently logged in member? I want to avoid this.
In fact, this GetCurrentMemberAsync() method works in a razor view, but not in the apicontroller. Why is that?
Hi Ras,
what version of Umbrac are you using?
In my api controller I use the MemberManager for this (Umbraco 10+)
Hi Huw,
Yes, this ended up being the correct method after all. The problem was on my end, as I was sending the API calls through Postman, I guess the system doesn't use the session or something like that? When I made the query through the browser, I was able to retrieve the currently logged in member. I am also on Umbraco 10.
is working on a reply...