Umbraco覆盖或扩展默认会员提供商

时间:2014-03-28 05:42:31

标签: umbraco

我想在Umbraco 6.1.6中使用不同的提供程序,例如我有这个

    <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear />
    <add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Website" passwordFormat="Hashed" umbracoApprovePropertyTypeAlias="isActive" umbracoLastLoginPropertyTypeAlias="loginDate" />
        <add name="UsersMembershipProvider" type="umbraco.providers.UsersMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" />
      </providers>
    </membership>

但我想用这个

<membership defaultProvider="TechBureauMembershipProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear/>
        <add name="TechBureauMembershipProvider" type="TechBureau.Web.providers.TechBureauMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Website" passwordFormat="Hashed" umbracoApprovePropertyTypeAlias="isActive" umbracoLastLoginPropertyTypeAlias="loginDate"/>
        <add name="UsersMembershipProvider" type="umbraco.providers.UsersMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false"/>
      </providers>
    </membership>

因为我想覆盖ResetPassword密码功能而不做任何事情。

public class TechBureauMembershipProvider : UmbracoMembershipProvider
{
    /// <summary>
    /// Overriding this so that it does nothing, reseting a password to a random password isn't cool for anyone.
    /// </summary>
    /// <param name="username"></param>
    /// <param name="answer"></param>
    /// <returns></returns>
    public override string ResetPassword(string username, string answer)
    {
        return string.Empty; //base.ResetPassword(username, answer);
    }
}

但问题是如果我这样做,会员标签不会加载。

2 个答案:

答案 0 :(得分:4)

大卫走在正确的道路上,但我不相信这里需要反射覆盖。 更改UmbracoMembershipProvider的类型,但保持名称相同。

        <membership defaultProvider="TechBureauMembershipProvider" userIsOnlineTimeWindow="2880">
        <providers>
            <clear/>
            <add name="UmbracoMembershipProvider" type="TechBureau.Web.providers.TechBureauMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Member" passwordFormat="Hashed"/>
            <add name="UsersMembershipProvider" type="umbraco.providers.UsersMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" passwordFormat="Hashed"/>

答案 1 :(得分:2)

我认为&#34; umbraco.cms \ businesslogic \ member \ Member.cs&#34;文件将提供者名称硬编码为:

public static readonly string UmbracoMemberProviderName = "UmbracoMembershipProvider";

因此您可能必须使用反射覆盖该函数。