tugberkugurlu / AspNetCore.Identity.MongoDB

MongoDB Data Store Adaptor for ASP.NET Core Identity
MIT License
230 stars 69 forks source link

Don't use UserName as the Id and make it possible to change it #29

Closed paulallington closed 7 years ago

paulallington commented 7 years ago

The ID property of a user is being set to the users email address. This is problematic for a few reasons.

Passing an email around as an ID is sometimes challenging. When passed in a url it is a users email address which may create data protection issues.
While I get it's potentially useful, as soon as a user changes their email address it's a PITA.

tugberkugurlu commented 7 years ago

@paulallington it's not e-mail, it's the username: https://github.com/tugberkugurlu/AspNetCore.Identity.MongoDB/blob/44870eac70224f58147a74c41e99c4f1f7e01ef9/src/AspNetCore.Identity.MongoDB/MongoIdentityUser.cs#L36

tugberkugurlu commented 7 years ago

@paulallington and changing the username is not supported: https://github.com/tugberkugurlu/AspNetCore.Identity.MongoDB/blob/44870eac70224f58147a74c41e99c4f1f7e01ef9/src/AspNetCore.Identity.MongoDB/MongoUserStore.cs#L181

However, I do think this is harsh and I probably carried this over from the RavenDB implementation. As MongoDB supports unique indexes, I do think that Id should be something uniquely generated (ObjectId) rather than the username.

paulallington commented 7 years ago

My apologies - username (they're just emails in my app). I didn't mean to come across harsh, I didn't say it was wrong or a bug, just some reasons for why it's potentially problematic.

tugberkugurlu commented 7 years ago

@paulallington no, you are right. I didn't see it that way. This should change, I have put this among the issues which should be fixed. Thanks for the feedback and keep them coming 👍

tugberkugurlu commented 7 years ago

@paulallington ow, sorry! I know what you mean now 😄 I meant the behaviour of the library is harsh, not you 😄 apologies, sorry again.

haamond commented 7 years ago

Hi guys, I do agree with @paulallington. and ObjectId (as a string) is good option.

tugberkugurlu commented 7 years ago

fixed by #32.