Copied to clipboard

Flag this post as spam?

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


  • Chris Dennett 2 posts 72 karma points
    Oct 24, 2023 @ 15:37
    Chris Dennett
    0

    Umbraco.Cms.Core.Security.IMemberManager.CreateAsync Failed : IdentityErrorUserStore

    Umbraco version 10.4.0

    I'm having some trouble with the CreateAsync() function of the UmbAlternativeRegisterController class. Here is the very stripped down code we are using, which is falling through to the else{} branch of the conditional check at the bottom:

    namespace UmbracoCTUIR.Core.Controllers
    {
        public class UmbAlternativeRegisterController : SurfaceController
        {
    
    private async Task<IdentityResult> RegisterMemberAsync(RegisterModel model, bool logMemberIn = true)
            {
                using ICoreScope scope = _coreScopeProvider.CreateCoreScope(autoComplete: true);
    
                if (string.IsNullOrEmpty(model.Name) && string.IsNullOrEmpty(model.Email) == false)
                {
                    model.Name = model.Email;
                }
    
                model.Username = model.UsernameIsEmail || model.Username == null ? model.Email : model.Username;
    
                var identityUser =
                    MemberIdentityUser.CreateNew(model.Username, model.Email, model.MemberTypeAlias, true, model.Name);
                IdentityResult identityResult = await _memberManager.CreateAsync(
                    identityUser,
                    model.Password);
    
                if (identityResult.Succeeded)
                {
                    //success code
                }
                else
                {
                    _logger.LogInformation(identityResult.ToString());
                }
            }
        }
    }
    

    The else{} branch LogInformation call is returning an error of Failed : IdentityErrorUserStore, but I'm not sure why. In my actual code, I have validated all of the arguments of the CreateAsync call, as well as the arguments of the MemberIdentityUser.CreateNew call being used to create the identityUser object above it. Both seem to be valid and error free. Any help identifying what I might be missing would be greatly appreciated.

    Thank you.

Please Sign in or register to post replies

Write your reply to:

Draft