nikitamalinov / paulgrahamessays

https://paulgrahamessays.com
0 stars 0 forks source link

Fix Allow users to sign in using google and save their progress with gitauto model #14

Open gitauto-ai[bot] opened 3 months ago

gitauto-ai[bot] commented 3 months ago

Original issue: #13

What is the feature

This feature allows users to sign in using Google and save their progress on the website.

Why we need the feature

Currently, users can mark lessons as complete, but this progress is saved in cookies, which is not ideal for long-term storage and can be lost easily. By integrating Google sign-in and using Redis for storing progress, we can provide a more reliable and persistent user experience. This also allows users to access their progress from any device once they are signed in.

How to implement and why

  1. Add Google Sign-In Button:

    • Implement a Google sign-in button in the navbar using NextAuth.js.
    • This will allow users to authenticate using their Google accounts.
  2. Integrate NextAuth.js:

    • Configure NextAuth.js to handle Google OAuth authentication.
    • Update the _app.js file to include the NextAuth provider.
  3. Set Up Redis for Progress Storage:

    • Install and configure Redis to store user progress.
    • Create a Redis client in the lib directory for interacting with the Redis database.
  4. Update Progress Storage Logic:

    • Modify the current logic that saves progress in cookies to instead save progress in Redis.
    • Create a set in Redis for each user identified by their email.
    • Store the URLs of completed lessons in the user's set.
  5. Update Progress Retrieval Logic:

    • When loading the homepage, retrieve the user's progress from Redis.
    • Display the progress with checkmarks by checking the URLs in the Redis set for the user.
  6. Handle Progress Removal:

    • Implement functionality to remove URLs from the user's set in Redis when they unmark a lesson as complete.
  7. Testing and Validation:

    • Thoroughly test the new authentication and progress storage mechanisms.
    • Ensure that progress is accurately saved and retrieved across different sessions and devices.

By following these steps, we can ensure a seamless and reliable user experience for tracking lesson progress.

Test these changes locally

git checkout -b gitauto/issue-#13-35fedc2f-bd04-435a-8137-f14e42f3c2b4
git pull origin gitauto/issue-#13-35fedc2f-bd04-435a-8137-f14e42f3c2b4
vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
paulgrahamessays 🛑 Canceled (Inspect) May 19, 2024 6:28pm