Copied to clipboard

Flag this post as spam?

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


  • satish 8 posts 29 karma points
    Oct 15, 2014 @ 13:30
    satish
    0

    Unable to SetPassword for a Member created through MemberService - API

    Hi,

    I've created a new member through Memberservice (API)  but I unable to set the default password while creating a member,

    var member = memService.CreateMember(model.LoginId, model.Email, model.DisplayName, "RegisteredUser");

    memService.SavePassword(member,"welcome");

    but when I tried to login using the same member via api (using umbraco provider) it doesnot get succeed. for the same member I can set password from backoffice and then it lets me to login via application. Also noticed after new member is created from my app password is blank in backoffice, does that mean the password is not sent from my app to Umbraco ? I tried logging with blank password from my app but still no use.

    could someone help me whats happening here. I am using Umbraco 7.x

    Regards

    Satish

     

  • Phil Gilligan 25 posts 136 karma points
    Oct 16, 2014 @ 10:39
    Phil Gilligan
    0

    Hi Satish, 

    The only way I could find to do this was by creating a hashed password like this:

    http://our.umbraco.org/wiki/reference/api-cheatsheet/users,-user-types-and-permissions/add-user-with-hashed-password

    Then setting the password by setting the 'RawPasswordValue' property on the member to the hashed value.

    I've tested it and it works but if anyone knows a better way, please let Satish and me know.

    Kind Regards,

    Phil

  • Phil Gilligan 25 posts 136 karma points
    Oct 16, 2014 @ 12:34
    Phil Gilligan
    0

    Update:  I'm using Umbraco v7.1.4 and there is definitely something odd going on with the member service 'SavePassword' method.  If you haven't explicitly saved the member before calling save password you will either get:

    • A blank password if it's the first member in the database,

    or

    • The preceding member's password will be overwritten with the one you just created.

    which is probably why you can't log in.

    The Services.MemberService.CreateMember method also seems to be allowing members with duplicate email addresses to be created even though requiresUniqueEmail="true" is set in web.config.

    I think I'll log this with the core team to see if these are known issues.

  • satish 8 posts 29 karma points
    Oct 17, 2014 @ 13:03
    satish
    1

    Thanks Phil. yes I have sorted out this.. password can be set only after profile is saved. 

  • Phil Gilligan 25 posts 136 karma points
    Oct 17, 2014 @ 13:19
    Phil Gilligan
    0

    Thanks Satish, I was coming to the same conclusion.  It seems that in the new members API, the member is only persisted after it is created (unless you use CreateMemberWithIdentity) which is slightly different to how it worked in the old API.  This is what gives you the funny blank password or password overwrites if you try to save a password without first saving the profile.

    I logged the duplicate password issue with the core team but it turns out that requiresUniqueEmail="true" is ignored by design to support a specific use case.

    Please see the issue ticket here with a suggestion of how to check for duplicate emails:

    http://issues.umbraco.org/issue/U4-5653

    Thanks to Sebastiaan from the core team for his input.

    Please mark as answered if you're happy with this outcome.

Please Sign in or register to post replies

Write your reply to:

Draft