Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tim 225 posts 690 karma points
    Nov 10, 2009 @ 18:11
    Tim
    0

    Is a default password set for Members created via: Member.MakeNew()

    If i create a new member via the MakeNew() method is a password generated by the system or do I need to then call the ChangePassword() method to set the password.

    Example:

    public void RegisterMember(string username, string memberType)
    {
        var type = MemberType.GetByAlias(memberType);
        var member = Member.MakeNew(username, type, new umbraco.BusinessLogic.User(0));
        member.Save();
    }

    or

    public void RegisterMember(string username, string password string memberType)
    {
        var type = MemberType.GetByAlias(memberType);
        var member = Member.MakeNew(username, type, new umbraco.BusinessLogic.User(0));
        member.Save();
        member.ChangePassword(password);
    }

    Also what is the most efficient way of creating a new member with a password that the member has specified during registration.

    Thanks

    Tim

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 10, 2009 @ 19:20
    Dirk De Grave
    2

    Tim,

    Just been checking the code for v4.1, and doesn't set the password upon MakeNew(). But, you should really use the memership functions to create a member. Check this wiki page for more info.

     

    Cheers,

    /Dirk

  • Tim 225 posts 690 karma points
    Nov 10, 2009 @ 20:21
    Tim
    0

    Hi Dirk,

    Thanks for the link to the documentation.

    Just a couple of quick questions:

    1. How can I set the memberType of a user created via the membership provider?

    2. How can I set properties of the newly created member.

    Do I need to create the user via the Membership.CreateUser() method and then get the created user via Member.GetMemberFromEmail() and set the properties etc there. Or can I cast from System.Web.Security.MembershipUser to umbraco.cms.businesslogic.member.Member?

    Tim

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 10, 2009 @ 21:47
    Dirk De Grave
    0

    Hi Tim,

    1/ You don't. umbraco's membership implementation does take care of that for you. All you need to do is to specify the attribute on the membership provider, just as you did before.

    2/ CreateUser() returns a MembershipUser, which you can (down)cast to a umbraco member. Ok, you got me there. You'll have to rely on the member api there to set/update properties on the member object (unless for generic properties such as Email, UserName, etc... as specified here).

     

    Hope this helps.

    Regards,

    /Dirk

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Nov 10, 2009 @ 23:30
Please Sign in or register to post replies

Write your reply to:

Draft