Open mgroves opened 1 year ago
Summary: The Conduit spec requires email for login, but otherwise username is used by most other endpoints. I'm making the assumption that login will happen less frequently than other operations, so therefore the overall app will be less affected by the overhead of SQL when using it for login and k/v elsewhere.
Endpoint analysis:
Handlers that needs changed:
GetCurrentUserHandler
- get username from claim instead of email, use GetUserByUsername instead of GetUserByEmailUpdateUserHandler
- use GetUserByUsername instead of GetUserByEmailData access that needs changed:
UserDataService::GetUserByEmail
- should use SQL++ instead of key/valueUserDataService::GetUserByUsername
- should use key/value instead of SQL++UserDataService::RegisterNewUser
- use username as key, not emailUser
Model - Username should get [JsonIgnore], not EmailUserDataService::UpdateUserFields
- this can now update email, can no longer change username, use username as key instead of emailUserDataService::GetProfileByUsername
- use k/v instead of SQL++UserDataService::DoesExistUserByEmailAndUsername
- switch around username/email address usageAuth changes:
AuthService::GenerateJwtToken
Put username in the JWT claims (maybe in addition to email?)AuthService
- will probably need a GetUsernameClaim
Migration changes:
CreateIndexOnUsernameFieldInUsersCollection
- since this is the latest migration, just rename and change it to index email instead of usernameValidator changes:
Controllers/Endpoints changes:
I think this went pretty smoothly. All tests are passing, and a manual run-through of the endpoints is working okay.
Seems like username is a better choice for document key, especially since endpoints Follow, Unfollow, and Get profile all have username in their URL. Username is going to be used more for lookups than Email. Using a K-V operation in Couchbase is faster than a SQL query, if the result is only ever supposed to be ONE user/profile. So therefore, refactor to use K-V more often.