feat: add OAuth, leaderboard, stats, account linking#54
Open
xrvnd wants to merge 1 commit into
Open
Conversation
Contributor
|
@xrvnd is attempting to deploy a commit to the coderzs' projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #39
This PR implements Google OAuth login, cross-device stat syncing, a public leaderboard, and a redesigned Statistics modal: following the interface pattern of games like
wafflegame.netas suggested. Tried my best to replicate functionality.Changes
Authentication
NextAuthwith Google OAuth provider/loginpage: email input (for previous user) and a "Continue with Google" buttonSessionProvideradded to root layoutDatabase schema
Usermodel into identity (name,email,provider,providerId,countryCode) and a newUserStatsmodel (played,totalStars,currentStreak,bestStreak,starDistribution) : separated as discussed, need reviewupsertGoogleUserchecks if a user (google user) already exists using (provider,providerId). If the user exists, it returns the existing user; otherwise, it creates a new one. This prevents duplicate accounts when the same user logs in again. (Running it multiple times does not create duplicates or break anything)Leaderboard
GET /api/leaderboardendpoint returns top 10 authenticated users ordered bytotalStars(anonymous users are not included)MAX_LEADERBOARD_USERScurrently at 10 (as discussed)Statistics modal
StatBox+StarBardesign. This tab shows "Secure your stats with a free account. Log in or Sign up" footer for guests --> shows signed-in name for authenticated usersMenu
/loginPLAYER IDfooter in all statesTest plan
PUT /api/new-usercreates aUserrow (identity only) + aUserStatsrow with zero statsGET /api/puzzle/statusreads stats fromUserStats, notUser/loginpage renders with email input and Google buttonlogin_hint/dailyGET /api/leaderboardreturns only authenticated users, ordered bytotalStarsdescLooking forward to get my code reviewed