Last updated
Was this helpful?
Last updated
Was this helpful?
IMemberManager
has a variety of methods that are useful for managing members in controllers and views. In this article, we'll have a look at how some of these can be used.
There are different ways to reference IMemberManager
:
The recommended way is to create a or Service and inject IMemberManager
in the constructor:
Alternatively, IMemberManager
can be injected directly into a template:
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 inject IIdKeyMap
service:
Udi
Guid
Finds a member by their email.
Finds a member by their login name.
The IMemberManager
methods returns members as MemberIdentityUser
.
Since Members Types are defined like Content Types in Umbraco, members can hold any number of properties. To access these properties, it can be beneficial to convert the member into an IPublishedContent
instance.
This is done using AsPublishedMember(MemberIdentityUser)
::
Returns the currently logged in member if there is one, else returns null value.
Returns the ID of a member.
Checks if the current request contains a logged-in member.
Checks if the current member is authorized as specific member types, member groups or concrete members.
For instance, you can use this method to verify if the current logged in member is part of a specific group:
Validates that specific member credentials are correct (without performing a log-in).
Returns a Task<bool>
specifying if the content with a given has public access restrictions set.
Returns a Task<bool>
specifying if the currently logged in member has access to the content given its .
Using the IMemberManager