Try our conversational search powered by Generative AI!

How to add/link additional user info to the newly created users?


 Currently I am using default Alloy RegisterController using ASP.NET Identity . It is used for Admin Account for the first time only, so I have made some modification to allow general user log in. The method-UIUserProvider.CreateUser  only allows to save username, password, email, passwordQuestion, passwordAnswer, isApproved, UIUserCreateStatus status and errors. How to add/link additional user info to the newly created users? I may have to add additional info during or after registration.

Apr 02, 2019 9:48

The UIUserProvider is used for creating user within limitting input information.

If you want to add more infomation freely while registering new user then you could use ApplicationUserManager<ApplicationUser> instead of using UIUserProvider

Edited, Apr 02, 2019 10:47

Can you provide simple sample of ApplicationUserManager<ApplicationUser>? The one in QuickSilver is complex and entangled with much code to begin with. I used the code below which gives me null.

 public ApplicationUserManager UserManager
                return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
            private set
                _userManager = value;
Edited, Apr 02, 2019 11:46

Here is simple sample of  ApplicationUserManager<ApplicationUser> to create a new user

var userManager = ServiceLocator.Current.GetInstance<ApplicationUserManager<ApplicationUser>>();
userManager.Create(new ApplicationUser() {Username = "test", Email = "", IsApproved = true}, "Password4Test");
Apr 02, 2019 12:07

When I used the code you provided, I am getting the following error.

No default Instance is registered and cannot be automatically determined for type 'IUserStore<ApplicationUser>'

There is no configuration specified for IUserStore<ApplicationUser>

1.) new ApplicationUserManager(*Default of IUserStore<ApplicationUser>*)
2.) ApplicationUserManager
3.) Instance of ApplicationUserManager
4.) Container.GetInstance(Login.ApplicationUserManager)

Exception Details: StructureMap.StructureMapConfigurationException: No default Instance is registered and cannot be automatically determined for type 'IUserStore<ApplicationUser>'

Edited, Apr 03, 2019 5:04

It is so weird. I did it successfully before based on this example

There may be a change for this stuff with new episerver version. I will try to find out the problem when I have time

Apr 03, 2019 6:08

Injecting last two dependencies provided me Usermanager object.

 context.Services.AddTransient<IContentRenderer, ErrorHandlingContentRenderer>()
                    .AddTransient<ContentAreaRenderer, AlloyContentAreaRenderer>()
                    .AddTransient<IUserStore<ApplicationUser>, UserStore<ApplicationUser>>()
                    .AddTransient<DbContext, ApplicationDbContext>();
Apr 03, 2019 9:39

Great! You are right. These were not registered automatically by Episerver.

Edited, Apr 03, 2019 10:31
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.