Last updated
Last updated
IMemberManager
is an user manager interface for accessing member data in the form of MemberIdentityUser
and converting it to IPublishedContent
. IMemberManager
has a variety of methods that are useful in views and controllers. For the list of methods, see the .
There are different ways to reference MembershipHelper:
While working with templates, the methods are available when you inject @IMemberManager
to access member data:
UmbracoAuthorizedApiController
has been removed from Umbraco 14. Use ManagementApiControllerBase
class instead.
UmbracoApiController
is obsolete in Umbraco 14 and will be removed in Umbraco 15.
If you wish to use the IMemberManager
in a class that inherits from one of the Umbraco base classes (eg. SurfaceController
, UmbracoApiController
, or UmbracoAuthorizedApiController
), you can use Dependency Injection. For instance, if you have registered your own class in Umbraco's dependency injection, you can specify the IMemberManager
interface in your constructor:
IMemberManager
has multiple ways to find members.
Finds a member by their ID
If we want to find a member by Udi
or Guid
we need to to inject IIdKeyMap
service:
Find member by Udi
Find member by Guid
Finds a member by their email.
Finds a member by their login name.
By default IMemberManager
returns members as MemberIdentityUser
. This method allows you to convert a MemberIndentityUser
into IPublishedContent
:
Returns the currently logged in member if there is one, else returns null value.
Returns the user id of a user
Checks if a member is logged in.
Checks if the current member is authorized for content protected by types, groups or specific members. For instance, you can use this method to check if the current logged in member is authorized. This is particularly useful for pages only available to the VIP member group, like so:
MemberManager
can also be used to manage users.
Validates that a user's credentials are correct without logging them in.
Returns a Task<bool>
specifying if the page with a given has public access restrictions set.
Returns a Task<bool>
specifying if the currently logged in member has access to the page given its .
Using the IMemberManager