Umbraco-cms: GetCurrentMember has empty email and username

Created on 3 Jul 2019  路  3Comments  路  Source: umbraco/Umbraco-CMS

When retrieving the current member using the Umbraco.Web.Security.MembershipHelper.GetCurrentMember() I get empty values for Email and Username.

Reproduction

Steps to reproduce

  • Make sure you have a member stored in Umbraco with an email address and a username
  • Make sure that user is logged in
  • In your code (in our case our BaseSurfaceController) call Members.GetCurrentMember().
  • Try to retrieve the values for Email and Username

Expected result

I would expect the Email and Username property to be filled with the data from the member.

Actual result

They are empty

Good to know

GetCurrentLoginStatus() does give me the correct Email and Username

I'm using Umbraco 8.0.2

Most helpful comment

The recommended way to get the email and username is to use Members.GetCurrentMemberProfileModel() which should give you the results you're looking for:

image

All 3 comments

The recommended way to get the email and username is to use Members.GetCurrentMemberProfileModel() which should give you the results you're looking for:

image

I would like to "reopen" this one,

When I work with custom properties on a member I can't access these custom properties from the ProfileModel returned by GetCurrentMemberProfileModel().

Is there any reason that GetCurrentMember() returns a lot of information but not username and email? I think that this is strange, all values (like umbracoMemberLockedOut, umbracoMemberLastLockoutDate etc are passed to the "Properties" collection if the IPublishedContent but the values are not there - given this GetCurrentMember should be market as obsolete if it does not work as one would expect.

From 8.2.0 onwards this will make a bit more sense: https://github.com/umbraco/Umbraco-CMS/issues/6227

Was this page helpful?
0 / 5 - 0 ratings