Copied to clipboard

Flag this post as spam?

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


  • Denford 132 posts 323 karma points
    Aug 11, 2014 @ 10:59
    Denford
    0

    Create member with MemberService.CreateWithIdentity

    I take it this new membership service doesnt automatically hash the given password or am i using this wrong. I have noticed the member password is saved in plain text when i create a new member but the log process i.e. either Membership.ValidateUser() or memberShipHelper.Login() tries to log in the user with the given password as hashed.

    So with both in place my newly created members couldnt log in regardless of the web config membership providers are set to use the password formatt as hashed. So my work around at the moment is to either hash the password myself with my own class or create the member first with MemberService.CreateMember() then call MemberService.SavePassword() immediately after creating the member (which i belive this call is mainly to update the password when changed or updated).

    Dont know if its me here but should this hash the password by default since every other call does use a hashed password, so unless if you set it otherwise this should be the default method, probably there is a reason hwy just cant see it at the moment, not to memntion the documentation doesnt mention anything about it.

    http://our.umbraco.org/Documentation/Reference/Management-v6/Services/MemberService

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Oct 09, 2014 @ 17:37
    Martin Griffiths
    0

    Bump! Same for me!

  • Denford 132 posts 323 karma points
    Oct 10, 2014 @ 07:23
    Denford
    0

    Quite annoying isnt it lol, well MemberService.SavePassword() seems to be the way i gues,no officical word from the Umbraco gurus though about how exactly this should work.

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Oct 10, 2014 @ 09:09
    Martin Griffiths
    0

    I reverted back to the standard .net method which works fine and created the object so I could easily pass in property data to the member. The member profile stuff is a faff!.

  • Dan Diplo 1554 posts 6205 karma points MVP 5x c-trib
    Oct 10, 2014 @ 10:44
    Dan Diplo
    1

    Apparently you are supposed to use the MemberShipHelper class for creating members, rather than directly via the Member Service. I only discovered this by accident by talking to a core developer, as it wasn't well documented. For instance, creating members via the Membership Service doesn't do any real checks - so you can actually create two members with the exact same username.

    However, I'm pretty sure you can create a hashed password using the Member Service - I'm sure I've done something like this before:

    var memberService = this.UmbracoContext.Application.Services.MemberService;
    
    var memberGroupService = this.UmbracoContext.Application.Services.MemberGroupService;
    
    var newMember = memberService.CreateMemberWithIdentity(this.Model.Username, this.Model.Email, this.Model.Name, this.Model.MembershipTypeAlias);
    
    newMember.IsApproved = false;
    
    memberService.SavePassword(newMember, this.Model.Password);
    
    memberService.Save(newMember);
  • Denford 132 posts 323 karma points
    Oct 13, 2014 @ 09:48
    Denford
    0

    @danDiplo yes that how i ended up doing it i actually have a hybrid of the two use the membership helper to check if there is already a member logged in and if the email being registered is already used. Then call on the member service to actually create the member, add custom properites save that member first then add the password after. NB save the member first then assign the password after as it will not have a db member yet to put the password onto, caught me out that.

Please Sign in or register to post replies

Write your reply to:

Draft