Try our conversational search powered by Generative AI!

AspnetIdentity - ApplicationUserProvider<TUser>

Vote:
 

We are importing an existing user base to our new episerver project.  The legacy cms had a salt value per user row, so I created a custom application user and introduced teh additional property of Salt value.

All is implemented fine, but I am having some problems with the above class, the abstract CreateUser method defines a fixed number of arguments, so I cant add my new salt value method.  One work around I had thought of was to perform an update immediately after creation with the salt value, not ideal but it would work.  However, I would like the admin users to still be able to use the create user facility in the backend and this will only make use of createuser method with no salt value.

Is there a way to replace the create user method globally, or alter the admin ui create user function to also perform the additional update?

#180925
Aug 02, 2017 17:33
- Mar 03, 2020 7:29
Hi Adam,
Can you guide me how did you created a custom application user. Any reference.

Dipak
Vote:
 

Hello Adam

This may be able to help: https://www.dcaric.com/blog/how-to-intercept-the-user-provider-in-episerver-10

#180948
Aug 02, 2017 22:56
Vote:
 

hi David, fantastic!  Thats exactly what I needed, thank you :)

#180970
Aug 03, 2017 18:39
Vote:
 

Hi Adam

Thats great news! If you find it useful can you mark as answered so other members of the community can benefit from the answer :)?

David

#180988
Aug 04, 2017 10:11
Vote:
 

No problem.

What i did in the end was completely intercept the createuser call only and implemented the extra field.  To be able to do that you need to set the return value of the intercept and you will need an instance of the application user manager.  Currently I have implemented identity as per the alloy example, so its not instantiated through DI, in which case I got my instance of applicatioin user manager by injecting the httpcontext and passing an instance of the OwinContext to create an instance of application user manager (typed to my user).


If you have a multi user type (in terms of class, not role) then you might want to specify the type of UiUserProvider when declaring the intercept, for my example we only have the one type of user class so this wasnt necessary.

#180993
Edited, Aug 04, 2017 13:26
Vote:
 

Thanks for sharing your experience Adam! Happy inercepting :)

#180994
Aug 04, 2017 13: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.