Ensures that members are auto-approved if creating a member via the legacy members API.
This commit is contained in:
@@ -849,7 +849,16 @@ namespace umbraco.providers.members
|
||||
var approveStatus = GetMemberProperty(m, ApprovedPropertyTypeAlias, true);
|
||||
if (string.IsNullOrEmpty(approveStatus) == false)
|
||||
{
|
||||
bool.TryParse(approveStatus, out isApproved);
|
||||
//try parsing as bool first (just in case)
|
||||
if (bool.TryParse(approveStatus, out isApproved) == false)
|
||||
{
|
||||
int intStatus;
|
||||
//if that fails, try parsing as int (since its normally stored as 0 or 1)
|
||||
if (int.TryParse(approveStatus, out intStatus))
|
||||
{
|
||||
isApproved = intStatus != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1015,4 +1024,32 @@ namespace umbraco.providers.members
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds some event handling
|
||||
/// </summary>
|
||||
public class MembershipEventHandler : ApplicationEventHandler
|
||||
{
|
||||
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
|
||||
{
|
||||
Member.New += Member_New;
|
||||
}
|
||||
|
||||
void Member_New(Member sender, NewEventArgs e)
|
||||
{
|
||||
//This is a bit of a hack to ensure that the member is approved when created since many people will be using
|
||||
// this old api to create members on the front-end and they need to be approved - which is based on whether or not
|
||||
// the Umbraco membership provider is configured.
|
||||
var provider = Membership.Provider as UmbracoMembershipProvider;
|
||||
if (provider != null)
|
||||
{
|
||||
var approvedField = provider.ApprovedPropertyTypeAlias;
|
||||
var property = sender.getProperty(approvedField);
|
||||
if (property != null)
|
||||
{
|
||||
property.Value = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,10 @@
|
||||
<Project>{C7CB79F0-1C97-4B33-BFA7-00731B579AE2}</Project>
|
||||
<Name>umbraco.datalayer</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\umbraco.interfaces\umbraco.interfaces.csproj">
|
||||
<Project>{511F6D8D-7717-440A-9A57-A507E9A8B27F}</Project>
|
||||
<Name>umbraco.interfaces</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
|
||||
Reference in New Issue
Block a user