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

Open gitauto-ai[bot] opened 3 months ago

gitauto-ai[bot] commented 3 months ago

Original issue: #15

What is the feature

This feature allows users to sign in using Google and saves their progress in reading lessons using Redis instead of cookies.

Why we need the feature

Currently, user progress is saved in cookies, which is not a reliable or scalable solution. By integrating Google sign-in and using Redis for storing user progress, we can provide a more secure, scalable, and seamless user experience. This will also allow users to access their progress from any device once they are signed in.

How to implement and why

  1. Google Sign-In Integration:

    • Add a Google sign-in button in the navbar.
    • Use NextAuth.js to handle Google authentication.
    • Update the components/Navbar/index.tsx to include the Google sign-in button.
  2. Remove Cookie-Based Progress Storage:

    • Identify and remove the existing code that saves user progress in cookies.
    • This will involve changes in the components where lessons are marked as complete.
  3. Implement Redis for Progress Storage:

    • Set up Redis in the Next.js API.
    • Create a Redis set for each user identified by their email.
    • When a user marks a lesson as complete, add the page URL to the Redis set.
    • When a user removes a lesson, remove the page URL from the Redis set.
    • Ensure that the Redis operations are secure by verifying the user's idToken.
  4. Display Progress on Homepage:

    • On loading the homepage, fetch the user's progress from Redis.
    • Display the progress with checkmarks by checking the URLs in the Redis set for the user.
    • Update the pages/index.js and related components to fetch and display this data.
  5. Verify idToken in API:

    • Ensure that all API routes interacting with Redis verify the user's idToken.
    • This will secure the user's data and ensure that only authenticated users can modify their progress.

By following these steps, we can ensure a smooth transition from cookie-based storage to a more robust Redis-based solution, enhancing the overall user experience.

Test these changes locally

git checkout -b gitauto/issue-#15-18ea63a6-d844-47ea-bb7a-782509fd3399
git pull origin gitauto/issue-#15-18ea63a6-d844-47ea-bb7a-782509fd3399
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:45pm