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 #18

Closed gitauto-ai[bot] closed 3 months ago

gitauto-ai[bot] commented 3 months ago

Original issue: #17

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, and this information is saved in cookies. This approach has limitations, such as data loss when cookies are cleared and lack of synchronization across devices. By implementing Google sign-in and saving progress using Redis, we can provide a more robust and seamless user experience. Users will be able to access their progress from any device after signing in with their Google account.

How to implement and why

  1. Add Google Sign-In Button:

    • Add a Google sign-in button to the navbar using NextAuth.js for authentication.
    • This will allow users to sign in with their Google account.
  2. Remove Cookie-Based Progress Saving:

    • Remove the existing implementation that saves lesson progress in cookies.
    • This is necessary to transition to a more reliable storage solution.
  3. Implement Redis for Progress Saving:

    • Use the @vercel/kv package to interact with Redis.
    • When a user marks a lesson as complete, save the lesson URL in a Redis set associated with the user's email.
    • When a user removes a lesson, remove the lesson URL from the Redis set.
  4. Verify idToken in Next.js API:

    • Ensure that the idToken is passed and verified in the Next.js API routes.
    • This is crucial for securely fetching and modifying the user's progress data in Redis.
  5. Display Progress on Homepage:

    • On the homepage, check the Redis set for the signed-in user to display the correct progress with checkmarks.
    • This ensures that users see their progress accurately reflected.
  6. Update Components:

    • Modify the necessary components such as Navbar, BasicLayout, and PageLayout to integrate the new sign-in and progress-saving functionality.
    • Ensure that the UI updates correctly based on the user's sign-in status and progress data.

By following these steps, we can enhance the user experience by providing a reliable and synchronized way to track lesson progress across devices.

Test these changes locally

git checkout -b gitauto/issue-#17-c7922aae-1adf-4ee9-95cc-2327ac701b86
git pull origin gitauto/issue-#17-c7922aae-1adf-4ee9-95cc-2327ac701b86
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 ❌ Failed (Inspect) May 19, 2024 7:29pm