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
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.
Integrate NextAuth.js:
Configure NextAuth.js to handle Google OAuth authentication.
Update the _app.js file to include the NextAuth provider.
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.
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.
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.
Handle Progress Removal:
Implement functionality to remove URLs from the user's set in Redis when they unmark a lesson as complete.
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.
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
Add Google Sign-In Button:
Integrate NextAuth.js:
_app.js
file to include the NextAuth provider.Set Up Redis for Progress Storage:
lib
directory for interacting with the Redis database.Update Progress Storage Logic:
Update Progress Retrieval Logic:
Handle Progress Removal:
Testing and Validation:
By following these steps, we can ensure a seamless and reliable user experience for tracking lesson progress.
Test these changes locally