Aspnetcore: UserStore<> FindUserAsync

Created on 18 Mar 2020  路  5Comments  路  Source: dotnet/aspnetcore

Describe the bug

Why is the methode FindUserAsync of UserStore<> marked private and protected?
Because of public override Task<TUser> FindByIdAsync(string userId not respect the TKey of user this method is needed to access.

To Reproduce

Implement a custom UserStore with 麓long麓 as TKey for user.

C# public class UserStore : UserStore<User, Role, ModelContext, long, UserClaim, UserRole, UserLogin, UserToken, RoleClaim> {

area-identity

Most helpful comment

Sorry, I didn't get it, how to utilize FindByIdAsync when the user key's is long?

All 5 comments

You shouldn't be this far down, there are public apis for finding things by keys. But string is always the key for public apis, your store needs to do the necessary conversion against your user class.

This is by design, because TKey is just yet another layer of generics which frankly didn't work for consumers.

For what property is FindByIdAsync looking at, the email address? Maybe the name is somehow misleading? So you mean searching for a user by ID is something to avoid in general?

The user ID and the email field can be different, but our templates by default make them the same. However that's up to you, and you can change it.

Sorry, I didn't get it, how to utilize FindByIdAsync when the user key's is long?

In my User class I've override key as Int now to find it by FindByIdAsync ? any one has idea?

@blowdart I've TUser with Tkey as Int in DB. I am trying to create a override version of FindByIdAsync.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kevenvz picture Kevenvz  路  3Comments

ermithun picture ermithun  路  3Comments

FourLeafClover picture FourLeafClover  路  3Comments

aurokk picture aurokk  路  3Comments

githubgitgit picture githubgitgit  路  3Comments