polar icon indicating copy to clipboard operation
polar copied to clipboard

User.username should not be unique?

Open frankie567 opened this issue 9 months ago • 2 comments

Currently, the username property is unique on User model. It takes the value of the GitHub username.

However, it starts to cause issues when linking GitHub account (we need to check if the username doesn't already exist in the DB, besides the account ID). If we want to support more signin methods in the future, this will also likely cause issues (possible collisions of username).

I see two approaches to improve this situation:

1. Remove unique constraint over username

This would make username a pure display value without any strong semantics behind.

For the few places where we currently rely on the unique GitHub username (in particular get_user_by_github_username), we can simply store it on OAuthAccount model.

Pros

  • Easy to implement
  • Only one source of "user uniqueness": the email address

Cons

  • Prevents "GitHub style" user tagging/mentioning (@fvoron) in potential future features of Polar

2. Keep username unique, but then keep it stable

If we want to keep it unique, we have to make it stable and not update it whenever the user logs in with GitHub. Said another way, we should have our own "usernames list" and have features to manage it (ask for a username on signup, have a setting to change it, etc.).

Pros

  • Complex to implement
  • Mirrors the functioning of GitHub, so we'll be able to have tagging/mentioning (@fvoron) in potential future features of Polar

Cons

  • Makes the signup process more complex (+ "this username is already taken" frustration)

3. Do nothing

Assume that we'll probably stick only with GitHub, so things can stay as they are.

Pros

  • Nothing to do ¯_(ツ)_/¯

Cons

  • We really need to be sure this won't change. It'll probably be harder to fix this when we'll have thousands of users.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog :^)
Fund with Polar

frankie567 avatar Sep 15 '23 09:09 frankie567