Copied to clipboard

Flag this post as spam?

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


  • Jakob Lithner 61 posts 264 karma points
    Sep 11, 2018 @ 13:25
    Jakob Lithner
    0

    Members.Login not working

    I have experimented with member handling for a long time without getting it to work. I am really amazed how difficult this is in Umbraco!

    Everyone needs basically the same member handling to: register, login, logout, change email/username, change password, reset forgotten password. To do that in Umbraco in my view takes too much effort. It should be possible to scaffold a basic setup that can then be adjusted!

    The main problem though is that a lot of the functionality provided does NOT work! Can it be that a lot of this functionality has changed between versions and now is not consistent anymore? Should I use MemberService, MemberHelper, Members object, or maybe fallback to plain FormsAuthentication? Different examples tell my different things and so far I have not been able to setup a complete working flow.

    1) To make MemberService.SavePassword to work you need to change a setting in web.config: allowManuallyChangingPassword="true". It took me a lot of Googling to find out and now the handling is less secure. I want to create a member with initial password without compromising security settings.

    2) When I do a simple login with the method recommended (in the Umbraco.TV guides on membership that I tried to follow in detail) it just crashes with an obscure message. I run Members.Login and I can assure you that entered username and passwords are OK. This is my Exception:

    System.FormatException: 'The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. '

  • Jakob Lithner 61 posts 264 karma points
    Sep 11, 2018 @ 13:44
    Jakob Lithner
    0

    I thought it might not be the Members.Login that was wrong so I tried to set the password through the backoffice section.

    When I changed the password there it is now possible to login!

    Does this mean that MemberService.SavePassword does not work?

    I add the complete method that I just copied from the Umbraco.TV:

    public class MemberController : SurfaceController
    {
        public ActionResult Register(RegisterAcademyModel model)
        {
            if(!ModelState.IsValid)
            {
                return CurrentUmbracoPage();
            }
    
            // Ensure member does not already exist
            var memberService = Services.MemberService;
            if(memberService.GetByEmail(model.Email) != null)
            {
                ModelState.AddModelError("", "A member with that email already exists.");
                return CurrentUmbracoPage();
            }
    
            // Create member and login
            var member = memberService.CreateMember(model.Email, model.Email, model.Name, "academyMember");
            memberService.SavePassword(member, model.Password);
            memberService.Save(member);
            Members.Login(model.Email, model.Password);
    
            return Redirect("/");
        }
    }
    
  • Jakob Lithner 61 posts 264 karma points
    Sep 11, 2018 @ 13:54
    Jakob Lithner
    101

    Hurray, it works! There is nothing like rubber ducking :)

    Expressing my problem makes it suddenly much more clear. The whole issue was about the order in which I put the commands. SavePassword should be set AFTER calling Save for member.

    I still think this was a bit confusing and had appreciated some more help:

    1) Parts of the Umbraco.TV gave the impression this was the order to do it.

    2) Members.Login gave a very strange message that I think could have been more helpful like "Sorry, this member has no password set".

    3) MemberService.SavePassword could have given a warning "Sorry, you can not save a password before the member is saved".

    4) I still think some nice scaffolding would be helpful :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" button below.

    Continue discussion

Please Sign in or register to post replies