Class MembershipHelper
A helper class for handling Members
Inheritance
System.Object
Namespace:System.Dynamic.ExpandoObject
Assembly:umbraco.dll
Syntax
public class MembershipHelper
Constructors
MembershipHelper(ApplicationContext, HttpContextBase)
Declaration
[Obsolete("Use the constructor specifying an UmbracoContext")]
public MembershipHelper(ApplicationContext applicationContext, HttpContextBase httpContext)
Parameters
Type |
Name |
Description |
ApplicationContext |
applicationContext |
|
System.Web.HttpContextBase |
httpContext |
|
MembershipHelper(ApplicationContext, HttpContextBase, MembershipProvider, RoleProvider)
Declaration
[Obsolete("Use the constructor specifying an UmbracoContext")]
public MembershipHelper(ApplicationContext applicationContext, HttpContextBase httpContext, MembershipProvider membershipProvider, RoleProvider roleProvider)
Parameters
Type |
Name |
Description |
ApplicationContext |
applicationContext |
|
System.Web.HttpContextBase |
httpContext |
|
System.Web.Security.MembershipProvider |
membershipProvider |
|
System.Web.Security.RoleProvider |
roleProvider |
|
MembershipHelper(UmbracoContext)
Declaration
public MembershipHelper(UmbracoContext umbracoContext)
Parameters
MembershipHelper(UmbracoContext, MembershipProvider, RoleProvider)
Declaration
public MembershipHelper(UmbracoContext umbracoContext, MembershipProvider membershipProvider, RoleProvider roleProvider)
Parameters
Type |
Name |
Description |
UmbracoContext |
umbracoContext |
|
System.Web.Security.MembershipProvider |
membershipProvider |
|
System.Web.Security.RoleProvider |
roleProvider |
|
Properties
CurrentUserName
Returns the currently logged in username
Declaration
public string CurrentUserName { get; }
Property Value
Type |
Description |
System.String |
|
Methods
ChangePassword(String, ChangingPasswordModel, String)
Changes password for a member/user given the membership provider name and the password change model
Declaration
public virtual Attempt<PasswordChangedModel> ChangePassword(string username, ChangingPasswordModel passwordModel, string membershipProviderName)
Parameters
Type |
Name |
Description |
System.String |
username |
|
ChangingPasswordModel |
passwordModel |
|
System.String |
membershipProviderName |
|
Returns
ChangePassword(String, ChangingPasswordModel, MembershipProvider)
Changes password for a member/user given the membership provider and the password change model
Declaration
public virtual Attempt<PasswordChangedModel> ChangePassword(string username, ChangingPasswordModel passwordModel, MembershipProvider membershipProvider)
Parameters
Type |
Name |
Description |
System.String |
username |
|
ChangingPasswordModel |
passwordModel |
|
System.Web.Security.MembershipProvider |
membershipProvider |
|
Returns
CreateRegistrationModel(String)
Creates a model to use for registering new members with custom member properties
Declaration
public virtual RegisterModel CreateRegistrationModel(string memberTypeAlias = null)
Parameters
Type |
Name |
Description |
System.String |
memberTypeAlias |
|
Returns
GetByEmail(String)
Declaration
public virtual IPublishedContent GetByEmail(string email)
Parameters
Type |
Name |
Description |
System.String |
email |
|
Returns
GetById(Int32)
Declaration
public virtual IPublishedContent GetById(int memberId)
Parameters
Type |
Name |
Description |
System.Int32 |
memberId |
|
Returns
GetByProviderKey(Object)
Declaration
public virtual IPublishedContent GetByProviderKey(object key)
Parameters
Type |
Name |
Description |
System.Object |
key |
|
Returns
GetByUsername(String)
Declaration
public virtual IPublishedContent GetByUsername(string username)
Parameters
Type |
Name |
Description |
System.String |
username |
|
Returns
GetCurrentLoginStatus()
Returns the login status model of the currently logged in member, if no member is logged in it returns null;
Declaration
public virtual LoginStatusModel GetCurrentLoginStatus()
Returns
GetCurrentMember()
Returns the currently logged in member as IPublishedContent
Declaration
public virtual IPublishedContent GetCurrentMember()
Returns
GetCurrentMemberId()
Returns the currently logged in member id, -1 if they are not logged in
Declaration
public int GetCurrentMemberId()
Returns
Type |
Description |
System.Int32 |
|
GetCurrentMemberProfileModel()
Creates a new profile model filled in with the current members details if they are logged in which allows for editing
profile properties
Declaration
public virtual ProfileModel GetCurrentMemberProfileModel()
Returns
IsLoggedIn()
Check if a member is logged in
Declaration
Returns
Type |
Description |
System.Boolean |
|
IsMemberAuthorized(Boolean, IEnumerable<String>, IEnumerable<String>, IEnumerable<Int32>)
Returns true or false if the currently logged in member is authorized based on the parameters provided
Declaration
public virtual bool IsMemberAuthorized(bool allowAll = false, IEnumerable<string> allowTypes = null, IEnumerable<string> allowGroups = null, IEnumerable<int> allowMembers = null)
Parameters
Type |
Name |
Description |
System.Boolean |
allowAll |
|
System.Collections.Generic.IEnumerable<System.String> |
allowTypes |
|
System.Collections.Generic.IEnumerable<System.String> |
allowGroups |
|
System.Collections.Generic.IEnumerable<System.Int32> |
allowMembers |
|
Returns
Type |
Description |
System.Boolean |
|
IsProtected(String)
Check if a document object is protected by the "Protect Pages" functionality in umbraco
Declaration
public virtual bool IsProtected(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
The full path of the document object to check
|
Returns
Type |
Description |
System.Boolean |
True if the document object is protected
|
IsUmbracoMembershipProviderActive()
Returns true if the current membership provider is the Umbraco built-in one.
Declaration
public bool IsUmbracoMembershipProviderActive()
Returns
Type |
Description |
System.Boolean |
|
Login(String, String)
A helper method to perform the validation and logging in of a member - this is simply wrapping standard membership provider and asp.net forms auth logic.
Declaration
public virtual bool Login(string username, string password)
Parameters
Type |
Name |
Description |
System.String |
username |
|
System.String |
password |
|
Returns
Type |
Description |
System.Boolean |
|
Logout()
Logs out the current member
Declaration
public virtual void Logout()
MemberHasAccess(String)
Check if the current user has access to a document
Declaration
public virtual bool MemberHasAccess(string path)
Parameters
Type |
Name |
Description |
System.String |
path |
The full path of the document object to check
|
Returns
Type |
Description |
System.Boolean |
True if the current user has access or if the current document isn't protected
|
RegisterMember(RegisterModel, out MembershipCreateStatus, Boolean)
Declaration
public virtual MembershipUser RegisterMember(RegisterModel model, out MembershipCreateStatus status, bool logMemberIn = true)
Parameters
Type |
Name |
Description |
RegisterModel |
model |
|
System.Web.Security.MembershipCreateStatus |
status |
|
System.Boolean |
logMemberIn |
true to log the member in upon successful registration
|
Returns
Type |
Description |
System.Web.Security.MembershipUser |
|
UpdateMemberProfile(ProfileModel)
Updates the currently logged in members profile
Declaration
public virtual Attempt<MembershipUser> UpdateMemberProfile(ProfileModel model)
Parameters
Returns
Type |
Description |
Attempt<System.Web.Security.MembershipUser> |
The updated MembershipUser object
|