Copied to clipboard

Flag this post as spam?

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


  • Allan Hawkey 232 posts 303 karma points
    Jun 03, 2015 @ 18:41
    Allan Hawkey
    0

    Change Password and Forgotten Password

    Does anyone have a simple, easy to follow method for creating a Change Password page and a Forgotten Password (i.e. reset password and email it) page for MEMBERS in Umbraco 7.2.5?

    I am using the built-in functionality for login and login status, and am looking for something simple to enable the change / forgotten password pages.

    I don't need password retrieval right now, though I imagine that might be helpful to others.

    Thanks
    Allan

  • Allan Hawkey 232 posts 303 karma points
    Jun 12, 2015 @ 10:30
    Allan Hawkey
    0

    Anyone able to share any thoughts on this please??

    Thanks, Allan

  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    Jun 12, 2015 @ 16:09
    Robert Foster
    0

    Hi Allan, You probably want to create a SurfaceController (or APIController) and implement the ChangePassword and ResetPassword functionality in your own views - the Controller would just use the MembershipHelper which has methods like ChangePassword.

    It's always a good idea to take a look at how the core does it; do a search for ChangePassword, for example, and also search for MembershipHelper.

    Also, check out this documentation on MembershipHelper:

    https://our.umbraco.org/Documentation/Implementation/Query-Data/MemberShipHelper/index

  • Allan Hawkey 232 posts 303 karma points
    Jun 13, 2015 @ 09:31
    Allan Hawkey
    0

    Thanks Robert - though not being familiar with SurfaceControllers, I still have little idea where to start with this. Do you have some sample code by any chance, and details of what files I'd need to add where in the umbraco file structure? I doubt I'm the first, and won't be the last, to need a simple way of enabling members to change their passwords!

    Thanks, Allan

  • Robert Foster 459 posts 1820 karma points MVP 3x admin c-trib
    Jun 13, 2015 @ 10:46
    Robert Foster
    1

    Hi Allan, this should fill in the missing bits for you:

    https://our.umbraco.org/documentation/Getting-Started/Code/Forms-Controllers/

    I'd give you an example but its a little difficult on my phone at the moment 😊

  • Luke 110 posts 256 karma points
    Jun 15, 2015 @ 09:13
    Luke
    4

    Hiya,

    Change Password:

    [HttpPost]
    public ActionResult HandleUpdatePassword([Bind(Prefix = "passwordModel")]UpdatePasswordModel model)
    {
        try
        {
            if (ModelState.IsValid == false)
            {
                return CurrentUmbracoPage();
            }
            var memberService = Services.MemberService;
            var member = memberService.GetById(AppHelper.GetCurrentUserId());
            memberService.SavePassword(member, model.Password);
            TempData["UpdateSuccess"] = true;
        }
        catch { }
        return CurrentUmbracoPage();
    }
    

    Reset Password & Email To User:

    public ActionResult HandleResetPassword(ResetPasswordModel model)
    {
        if (ModelState.IsValid == false)
            return CurrentUmbracoPage();
        if (ModelState.IsValid)
        {
            var up = Services.MemberService.GetByEmail(model.UserName);
            if (up == null)
                up = Services.MemberService.GetByUsername(model.UserName);
            String Msg = "";
            if (up != null)
            {
                string email = up.Email;
                if (!string.IsNullOrEmpty(email))
                {
                    string passwd = System.Web.Security.Membership.GeneratePassword(6, 0);
                    Services.MemberService.SavePassword(up, passwd);
    // Send Email
    

    Hope this helps, L

  • Birger 14 posts 34 karma points
    Sep 07, 2015 @ 09:05
    Birger
    0

    Allan, did you get this working?

    I'm trying to create members from a list from a text file, but they all get created without passwords, so I have to edit all of them in backoffice afterwards, which makes the whole process of creating them like this kinda pointless.

    // Reading all lines from the file.
    string[] lines = System.IO.File.ReadAllLines(filePath, Encoding.UTF8);
    
    // Every line is a member.
    foreach (string line in lines)
    {
        // Splitting the line.
        // 0 name
        // 1 email
        // 2 club
        // 3 phone
        // 4 address
        // 5 zip
        string[] values = line.Split(',');
    
        var newMember = ApplicationContext.Current.Services.MemberService.CreateMemberWithIdentity(values[1], values[1], values[0], "RegularMember");
        ApplicationContext.Current.Services.MemberService.Save(newMember);
    
        newMember.SetValue("club", values[2]);
        newMember.SetValue("phone", values[3]);
        newMember.SetValue("address", values[4]);
        newMember.SetValue("zip", values[5]);
    
        ApplicationContext.Current.Services.MemberService.Save(newMember);
        ApplicationContext.Current.Services.MemberService.SavePassword(newMember,"123456");
    
    }
    

    The members are created, all member properties are set, but they can't log in with the given password...

  • Ultradata 16 posts 108 karma points
    May 14, 2019 @ 21:58
    Ultradata
    0

    Hi all,

    Is there any updates/enhancements anyone can make to this page before we kickoff adding 'Forgotten password' to Members functionality.

    Update: This looks interesting to my non-coder eyes. http://siempresolutions.co.uk/blog/Umbraco_Members_Part_3_A_Full_Solution

    Also, I was wondering if anyone has added 2FA to this process?

    Many thanks Lorraine :-)

Please Sign in or register to post replies

Write your reply to:

Draft