I need to retrieve the username of the current logged in member (front-end) from within an API controller, using the new Service APIs (I can do it with the legacy APIs but would prefer not to use deprecated functionality). However, I'm struggling to get a context to be able to get a valid MembershipHelper.
Thanks Oleg, but it's the MembershipHelper (http://our.umbraco.org/documentation/Reference/Querying/MemberShipHelper/) that I'm trying to get, rather than the MemberService.
Regardless, Umbraco.Core.ApplicationContext.Current.Services.MemberService still errors ('Umbraco.Web.UmbracoHelper' does not contain a definition for 'Core' ...etc).
//obtem o usuario corrente...
var memberService = ApplicationContext.Current.Services.MemberService;
var memberHelper = new Umbraco.Web.Security.MembershipHelper(Umbraco.Web.UmbracoContext.Current);
IPublishedContent membro = memberHelper.GetCurrentMember();
var m = memberService.GetById(membro.Id);
Get membershipHelper in API Controller
Hi,
I need to retrieve the username of the current logged in member (front-end) from within an API controller, using the new Service APIs (I can do it with the legacy APIs but would prefer not to use deprecated functionality). However, I'm struggling to get a context to be able to get a valid
MembershipHelper
.I've tried the following as per the documentation:
...but
Umbraco.Web.UmbracoContext.Current
errors, saying Umbraco.Web.UmbracoHelper does not contain a definition for 'Web'.Can anyone suggest how to get MembershipHelper correctly from in an API Controller?
Thanks.
Hi,
Try this
http://our.umbraco.org/documentation/Reference/Management-v6/Services/MemberService
Oleg
Thanks Oleg, but it's the MembershipHelper (http://our.umbraco.org/documentation/Reference/Querying/MemberShipHelper/) that I'm trying to get, rather than the MemberService.
Regardless,
Umbraco.Core.ApplicationContext.Current.Services.MemberService
still errors ('Umbraco.Web.UmbracoHelper' does not contain a definition for 'Core' ...etc).Any other ideas?
I'd missed the fact that the class inherits from
Umbraco.Web.WebApi.UmbracoApiController
, so gettingMembershipHelper
is as simple as this:... from which I can now derive the current member username, using the memberService which is declared as follows:
Hi!
I have the same problem. I soved as folow
(forgive my bad English)
is working on a reply...