BioDrop icon indicating copy to clipboard operation
BioDrop copied to clipboard

[FEATURE] Associate profile to logged in user

Open eddiejaoude opened this issue 3 years ago • 10 comments

Description

if username is different from logged in user, show a warning and have a button to update (this will only work if someone logged in before they changed their username)

USER

  • [ ] When user logs in associate the profile to their account using their GitHub username (maybe GitHub ID?)

Ideas...

  • I think the model models/Account.js needs to be updated to create a on-to-many relationship to models/Profile.js on login (or on profile update in PR #6998?)
  • then the queries in the app should not check Profile model for username but use the relationship of the logged in user
  • this will then help us resolve the issue of people changing their GitHub username and also allow people to create multiple profiles (in the future)

These 2 have been moved to their own issue https://github.com/EddieHubCommunity/LinkFree/issues/7349

  • [ ] ~~If the username no longer matches the logged in user, show an error of their previous associated username and their current GitHub username~~
  • [ ] ~~When displaying the error, have a button to update their username and their url will also change~~

~~Dependent on https://github.com/EddieHubCommunity/LinkFree/issues/7066~~

Screenshots

No response

Additional information

After this issue is complete, then this issue needs to be done https://github.com/EddieHubCommunity/LinkFree/issues/7349

eddiejaoude avatar May 21 '23 04:05 eddiejaoude

To reduce notifications, issues are locked until they are https://github.com/EddieHubCommunity/LinkFree/labels/%F0%9F%8F%81%20status%3A%20ready%20for%20dev and to be assigned. You can learn more in our contributing guide https://github.com/EddieHubCommunity/LinkFree/blob/main/CONTRIBUTING.md

github-actions[bot] avatar May 21 '23 04:05 github-actions[bot]

I can work on this issue but before that let me do some analysis to understand the flow. And I will come up with questions if any clarification is needed for the feature.

raviraj-github avatar Jun 05 '23 09:06 raviraj-github

Sure @raviraj-github any questions let me know - please note I removed 2 tasks from this issue description as they are in a separate issue that can be done after this (I like to keep issues/pull requests small) and I added some ideas/notes

eddiejaoude avatar Jun 05 '23 12:06 eddiejaoude

Analysis:

Link Free Flow:

  1. The user uploads a file with their GitHub username.
  2. They attempt to log in using their GitHub account.
  3. We retrieve the GitHub username from the account and load the corresponding profile details from the database.
  4. If the user has changed their GitHub username in the meantime, we are unable to load the profile with the changed username. In such cases, we consider the scenario a failure and prompt the user to either create a profile using GitHub or soon using a form.

Solution:

To address this issue, we can update the account schema to include references to profiles (establishing a one-to-many relationship). When a user logs in, we load all the profiles associated with the account and search for a profile with a matching username. If no matching profile is found, we can provide an option to update the username in the system using a UI button and text.

Challenges:

  1. When a user logs in for the first time, we need to find the profile using the GitHub username to link it to the account. However, if the user has uploaded the file and subsequently changed their username on GitHub before attempting to log in, we won't be able to link the profile, resulting in a similar problem.
  2. Another challenge is that the account schema appears to replicate the AuthJS format used in AuthJS. To support database operations, we have implemented a DB adaptor and written all the defined methods in AuthJS. It seems that AuthJS calls all the methods sequentially, including the create method every time we log in. Extending this schema may not be ideal. We should discuss this further. image

Alternate Solution: To overcome the challenges, we can extend the Profile schema to include both the GitHub user ID and the GitHub username. image

When uploading the profile to DB, we can retrieve the GitHub user information using the following API endpoint: "". We will then update the profile with the GitHub user ID. See the screenshot. image

During user login, instead of loading the profile with the username, we will load it with the user ID. Since the user ID remains constant, we will be able to find the profile reliably every time.

As for the issue of mismatched login usernames and profile usernames, we can display an error and prompt the user to update their username.

Future Considerations:

In the future, if we plan to create a sign-up page for our app or offer alternate login options, we need to decide which user ID to store. Should we allow a single user to log in through multiple third-party apps such as Gmail, Facebook, or GitHub? Typically, other websites only allow one app per user, and if a user attempts to log in through another channel, it would create a new account altogether.

Considering the possibility of having multiple profiles for one LinkFree user, I'm uncertain about the advantages or value we would gain from this arrangement. If we decide to extend the system to allow multiple profiles per LinkFree account in the future, we would need to update the Account Schema and carefully consider how to loosely couple it with Auth JS, ensuring it supports all types of logins, including our SignUp page.

In general, I believe it would be prudent to consider remodeling all our schemas at once, taking into account potential future use cases. This approach would ensure that we maintain backward compatibility and create a system that is future-proof.

Apologies for the delay; it took me two days to fully comprehend the complete flows. Instead of merely fixing the immediate issue, I believe it's important to address the problem in a way that ensures future-proofing and architectural suitability for both current and future use cases. I prefer taking a holistic approach to fixing problems rather than applying quick fixes.

Let's decide together and go ahead with the solution approach!

raviraj-github avatar Jun 07 '23 08:06 raviraj-github

As part of my experience, I encountered two product improvements that I believe are crucial for the development process. I have logged both issues.

  1. https://github.com/EddieHubCommunity/LinkFree/issues/7437
  2. https://github.com/EddieHubCommunity/LinkFree/issues/7438

raviraj-github avatar Jun 07 '23 10:06 raviraj-github

@raviraj-github this is great 👍 maybe we should discuss further on a community LinkFree call (aka office hours)? I am planning one for next Wednesday

eddiejaoude avatar Jun 07 '23 11:06 eddiejaoude

Yes, I can explain my analysis in the call. Let me know how I can join the call.

raviraj-github avatar Jun 07 '23 11:06 raviraj-github

Great! I think there are a few things to discuss with issue. Are you in the EddieHub Discord? We will add it to the events in there http://discord.eddiehub.org

eddiejaoude avatar Jun 07 '23 11:06 eddiejaoude

Yes. I joined the discord a week back. image

raviraj-github avatar Jun 07 '23 11:06 raviraj-github

Merged https://github.com/EddieHubCommunity/LinkFree/pull/8315

eddiejaoude avatar Jul 23 '23 07:07 eddiejaoude