Home > OS >  Is it mandatory to use IdentityUser in SignInManager?
Is it mandatory to use IdentityUser in SignInManager?

Time:09-17

I implemented the Asp.Net Core Identity framework in the lower layers of my project. I use classes such as UserManager and PasswordHasher in the business layer. In these layers I am not returning the IdentityUser directly, but instead returning DTOs.

I need to use SignInManager for Auth operations on Asp.Net Core MVC side, but this class takes a user parameter, is it mandatory to use IdentityUser here? I know it's not mandatory but I usually see it used with IdentityUser.

My other question is, if it is not mandatory, how is this a correct approach, will it cause me a problem in the future?

CodePudding user response:

As long as we stick with SignInManager, UserManager and all kind of Identity kind of stuff, use IdentityUser or any derived from it (like public class AppUser: IdentityUser).

how is this a correct approach, will it cause me a problem in the future?

Microsoft Identity on .net core was designed as a barebone, that could implement by multiple approach (EFCore, MongoDb, even Dapper,...).

So when we doesn't know how developers going to implementing stuff, just use something that have enough information to identified the user, along with all the other stuff (password, security stamp,...), so IdentityUser was choose cause she can satisfy them all. And personally, I think this approach is the most convenient way to implement the rest, regarding which storage engine we use.

And again, please don't try inventing another Identify mechanism, the platform itself wont let us down.

  • Related