You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We use value objects for the key IDs of our user and role objects. However, registration requires these values to be the same type when making a call to AddIdentityMongoDbProvider
Describe the solution you'd like
It would be nice to be able to define the key types for the user and role separately rather than forcing them to be the same type.
builder.Services.AddAuthorization().AddIdentityMongoDbProvider<ApplicationUser,ApplicationRole,UserId>(// <--- It would be nice to be able to specify the ID types for user and role separately
identityOptions =>{identityOptions.SignIn.RequireConfirmedAccount=false;},
mongoIdentityOptions =>{mongoIdentityOptions.ConnectionString=builder.Configuration.GetConnectionString("MongoDB");}).AddDefaultTokenProviders();
Describe alternatives you've considered
The alternative would be use the underlying type such as a Guid. However, you lose the strong typing of the value object. I'm also not sure registering a Guid serialiser for a nice readable guid currently works.
if anyone still interested in this feature, I've created branch. In the test site you can find user class TestSiteUser : MongoUser<ObjectId> and role class TestSiteRole : MongoRole<string>. Few things that you should know about using different keys:
you have to manually handle Id field (like UserController)
you have to provide serializer for TKey type. I used string as a type for TKey and it works because of default serializer. It won't work for Guid. In case of guid you'll need to register serializer like BsonSerializer.RegisterSerializer(new GuidSerializer(GuidRepresentation.Standard));. Other types most likely will require own serializer as well.
Is your feature request related to a problem? Please describe.
We use value objects for the key IDs of our user and role objects. However, registration requires these values to be the same type when making a call to
AddIdentityMongoDbProvider
Describe the solution you'd like
It would be nice to be able to define the key types for the user and role separately rather than forcing them to be the same type.
Describe alternatives you've considered
The alternative would be use the underlying type such as a Guid. However, you lose the strong typing of the value object. I'm also not sure registering a Guid serialiser for a nice readable guid currently works.
Example:
The text was updated successfully, but these errors were encountered: