Copied to clipboard

Flag this post as spam?

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


  • Jon 38 posts 157 karma points
    Nov 24, 2015 @ 21:39
    Jon
    0

    7.3 Identity Issues

    I have a member login built using UmbracoIdentity. (https://github.com/Shazwazza/UmbracoIdentity)

    The UserManager in the below code is returned as null. I have included the property that gets the UserManager.

    Why would this be null? Is this something to do with the UmbracoIdentity package or is it due to upgrades to 7.3 that break identity? I have read some rumblings about changes in 7.3 that could cause this but nothing specific enough for me to be sure.

    Any suggested fixes either way would be amazing!

        [HttpPost]
        [AllowAnonymous]
        public async Task<ActionResult> HandleLogin([Bind(Prefix = "loginModel")] LoginModel model)
        {
            if (ModelState.IsValid)
            {
                // UserManager is null here - WHY!?
                var user = await UserManager.FindAsync(model.Username, model.Password);
                if (user != null)
                {
                    await SignInAsync(user, true);
                    return RedirectToCurrentUmbracoPage();
                }
                ModelState.AddModelError("loginModel", "Invalid username or password");
            }
    
            return CurrentUmbracoPage();
        }
    
        public UmbracoMembersUserManager<UmbracoApplicationMember> UserManager
        {
            get
            {
                return _userManager ?? (_userManager = OwinContext
                    .GetUserManager<UmbracoMembersUserManager<UmbracoApplicationMember>>());
            }
        }
    
  • Jon 38 posts 157 karma points
    Nov 24, 2015 @ 22:34
    Jon
    0

    My UmbracoIdentityStartup was not being executed.

    I had this line in my web.config:

    <add key="owin:appStartup" value="UmbracoDefaultOwinStartup" />
    

    Commenting this out fixes the issue.

    I had not added this line so assumed it was something to do with the package, however examining the package further suggested otherwise.

    J

  • Jon 38 posts 157 karma points
    Nov 24, 2015 @ 23:05
    Jon
    0

    This fix breaks login to the back end.

    It appears this package is incompatible with the back end login, which makes me wonder how you're supposed to use it at all? =/

    So what do I do now? There must be some way to do this. Grr!

  • Shannon Deminick 1526 posts 5272 karma points MVP 2x
    Nov 25, 2015 @ 08:28
    Shannon Deminick
    1

    Hi, you cannot just ignore the umbraco OWIN startup. There can only be a single OWIN startup, so you need to combine all features.

    There's another package that might help:

    https://www.nuget.org/packages/UmbracoCms.IdentityExtensions

    Which will install some additional startup classes that you can use. See the UmbracoStandardOwinStartup class once you install that. Then use it in your appSettings. Then you need to enable the Umbraco Identity stuff on your own inside of this class:

    https://github.com/Shazwazza/UmbracoIdentity/wiki/Startup-Configuration

  • Shannon Deminick 1526 posts 5272 karma points MVP 2x
    Nov 25, 2015 @ 08:46
    Shannon Deminick
    100

    I've updated the docs a bit here: https://github.com/Shazwazza/UmbracoIdentity/blob/master/README.md

    I will make a new major version of this for Umbraco 7.3.2 once it is out and remove support for this project for Umbraco < 7.3.2.

  • Jon 38 posts 157 karma points
    Nov 25, 2015 @ 11:41
    Jon
    0

    That's great Shannon, thanks.

    I needed to add this line to UmbracoStandardOwinStartup to get both back end and front end playing happily together.

    app.UseUmbracoBackAuthentication();
    

    Thanks very much for your efforts!

Please Sign in or register to post replies

Write your reply to:

Draft