Copied to clipboard

Flag this post as spam?

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


  • Thomas Egebrand Gram 63 posts 138 karma points
    May 15, 2014 @ 12:42
    Thomas Egebrand Gram
    0

    Creating a "recover password"-page for members (Umbraco 7)

    Hello community!

    I'm in the middle of a project, attempting to create a page where members can recover their password. Unfortunately, i'm probably too much of a newbie with MVC to figure out where to start this journey. Is this already accessible via the new MemberService API?

    The recovery option must ask the member for his email (which is also the username), send the member an email with a link to reset, and then either give them a new password right away or allow them to enter a new one.

    I would love some pointers on where to go from here. Keep in mind that it's been a while since i created a surface controller, so be as kind as possible! :) Thanks!

    Also - perhaps this should be included in the new Member snippets?

    // Thomas

  • Dan 1285 posts 3917 karma points c-trib
    May 15, 2014 @ 12:57
    Dan
    1

    Hi Thomas,

    It would be great if this stuff was built into Umbraco, in a similar way to how there are new partials to render login/registration forms. As far as I know though - and it'd be fantastic if someone could demonstrate otherwise (perhaps using the new Membership API which I've not looked at yet!) - it's not. The best I've found is Warren Buckley's Standard Membership which has code for the complete member cycle. It's not a 'package' and it's not super-straight forward to integrate into a project but the code is there and is great for cherry picking. Be prepared for a bit of a learning curve if you're an MVC noob.

    I'd love it if someone had any quicker/easier solutions for doing this? Anyone...?

  • Chris Lord 15 posts 51 karma points
    May 15, 2014 @ 18:25
    Chris Lord
    0

    Hi Thomas,

    I have built a "forgotten password" function before that simply asks the member for their email (also their username). I then post this to a controller, use the MemberService to find the member. If the member exists, I generate a random password and email this to the user, and set a property on the member which I then use to force them to change this random password when they next login.

    Works well for me, probably other ways to achieve the same thing.

    Cheers

    Chris

  • Thomas Egebrand Gram 63 posts 138 karma points
    May 15, 2014 @ 23:13
    Thomas Egebrand Gram
    0

    @Dan - thanks for pointing me in that direction! :) I've been playing around a bit, trying to convert the entire thing into the new MemberService, but unfortunately it's a bit out of my league.. at least for right now!

    @Chris - Cool! Could you elaborate a bit on that? Like how did you manage to change a custom member property? I've been searching for ages trying to solve that one! :)

    createMember.GetProperty("hasVerifiedEmail").Value = false; 

    I have this currently, from the old Member code, but it would seem the new Member doesn't allow me to just take the property i want - only the MemberProperties[].

    Thanks!

    // Thomas

  • Chris Lord 57 posts 210 karma points
    May 16, 2014 @ 00:32
    Chris Lord
    1

    Hi Thomas,

    Use the MemberService to get the member and then update the properties;

    var ms = Services.MemberService;
    var member = ms.GetByUsername(model.Email); (or GetById etc etc)
    member.SetValue("passwordIsDefault", true);  (passwordIsDefault is a true/false prop on my member type)
    ms.Save(member);

    You can then do the same thing when you log the member in, but use member.GetValue("passwordIsDefault") and force the user to change their password.....

    That's it :-)

    Cheers

    Chris

  • Simon 692 posts 1068 karma points
    Jul 28, 2015 @ 12:49
    Simon
    0

    Hi Guys,

    Have you got the code snippet, for this functionality, including the generation of password, etcc..?

    Thank you guys..

Please Sign in or register to post replies

Write your reply to:

Draft