View Source
Class MembershipHelper
A helper class for handling Members
Inheritance
System.Object
Assembly: Umbraco.Web.dll
Syntax
public class MembershipHelper
Constructors
View Source
MembershipHelper(HttpContextBase, IPublishedMemberCache, MembershipProvider, RoleProvider, IMemberService, IMemberTypeService, IUserService, IPublicAccessService, AppCaches, ILogger)
Declaration
public MembershipHelper(HttpContextBase httpContext, IPublishedMemberCache memberCache, MembershipProvider membershipProvider, RoleProvider roleProvider, IMemberService memberService, IMemberTypeService memberTypeService, IUserService userService, IPublicAccessService publicAccessService, AppCaches appCaches, ILogger logger)
Parameters
Properties
View Source
CurrentUserName
Returns the currently logged in username
Declaration
public string CurrentUserName { get; }
Property Value
Type |
Description |
System.String |
|
View Source
HttpContext
Declaration
protected HttpContextBase HttpContext { get; }
Property Value
Type |
Description |
System.Web.HttpContextBase |
|
View Source
MemberCache
Declaration
protected IPublishedMemberCache MemberCache { get; }
Property Value
Methods
View Source
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
View Source
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
View Source
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
View Source
Get(Udi)
Declaration
public virtual IPublishedContent Get(Udi udi)
Parameters
Type |
Name |
Description |
Udi |
udi |
|
Returns
View Source
GetByEmail(String)
Declaration
public virtual IPublishedContent GetByEmail(string email)
Parameters
Type |
Name |
Description |
System.String |
email |
|
Returns
View Source
GetById(Guid)
Declaration
public virtual IPublishedContent GetById(Guid memberId)
Parameters
Type |
Name |
Description |
System.Guid |
memberId |
|
Returns
View Source
GetById(Int32)
Declaration
public virtual IPublishedContent GetById(int memberId)
Parameters
Type |
Name |
Description |
System.Int32 |
memberId |
|
Returns
View Source
GetByIds(IEnumerable<Guid>)
Declaration
public virtual IEnumerable<IPublishedContent> GetByIds(IEnumerable<Guid> memberIds)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Guid> |
memberIds |
|
Returns
View Source
GetByIds(IEnumerable<Int32>)
Declaration
public virtual IEnumerable<IPublishedContent> GetByIds(IEnumerable<int> memberIds)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Int32> |
memberIds |
|
Returns
View Source
GetByProviderKey(Object)
Declaration
public virtual IPublishedContent GetByProviderKey(object key)
Parameters
Type |
Name |
Description |
System.Object |
key |
|
Returns
View Source
GetByProviderKeys(IEnumerable<Object>)
Declaration
public virtual IEnumerable<IPublishedContent> GetByProviderKeys(IEnumerable<object> keys)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.Object> |
keys |
|
Returns
View Source
GetByUsername(String)
Declaration
public virtual IPublishedContent GetByUsername(string username)
Parameters
Type |
Name |
Description |
System.String |
username |
|
Returns
View Source
GetCurrentLoginStatus()
Returns the login status model of the currently logged in member.
Declaration
public virtual LoginStatusModel GetCurrentLoginStatus()
Returns
View Source
GetCurrentMember()
Returns the currently logged in member as IPublishedContent
Declaration
public virtual IPublishedContent GetCurrentMember()
Returns
View Source
GetCurrentMemberId()
Returns the currently logged in member id, -1 if they are not logged in
Declaration
public int GetCurrentMemberId()
Returns
Type |
Description |
System.Int32 |
|
View Source
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
View Source
GetCurrentUserRoles()
Gets the current user's roles.
Declaration
public IEnumerable<string> GetCurrentUserRoles()
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.String> |
|
View Source
GetUserRoles(String)
Declaration
public IEnumerable<string> GetUserRoles(string userName)
Parameters
Type |
Name |
Description |
System.String |
userName |
|
Returns
Type |
Description |
System.Collections.Generic.IEnumerable<System.String> |
|
View Source
IsLoggedIn()
Check if a member is logged in
Declaration
Returns
Type |
Description |
System.Boolean |
|
View Source
IsMemberAuthorized(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(IEnumerable<string> allowTypes = null, IEnumerable<string> allowGroups = null, IEnumerable<int> allowMembers = null)
Parameters
Type |
Name |
Description |
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 |
|
View Source
IsProtected(IEnumerable<String>)
Declaration
public virtual IDictionary<string, bool> IsProtected(IEnumerable<string> paths)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.String> |
paths |
|
Returns
Type |
Description |
System.Collections.Generic.IDictionary<System.String, System.Boolean> |
|
View Source
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
|
View Source
IsUmbracoMembershipProviderActive()
Returns true if the current membership provider is the Umbraco built-in one.
Declaration
public bool IsUmbracoMembershipProviderActive()
Returns
Type |
Description |
System.Boolean |
|
View Source
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 |
|
View Source
Logout()
Logs out the current member
Declaration
public virtual void Logout()
View Source
MemberHasAccess(IEnumerable<String>)
Checks if the current user has access to the paths
Declaration
public virtual IDictionary<string, bool> MemberHasAccess(IEnumerable<string> paths)
Parameters
Type |
Name |
Description |
System.Collections.Generic.IEnumerable<System.String> |
paths |
|
Returns
Type |
Description |
System.Collections.Generic.IDictionary<System.String, System.Boolean> |
|
View Source
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
|
View Source
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 |
|
View Source
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
|