login feature changes - #41
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the authentication UX and navbar behavior to support a full login → callback → post-login redirect flow, plus showing the authenticated user’s avatar/profile menu and providing a logout path that returns users to /login.
Changes:
- Adds
redirectpropagation through/loginand/login/callbackso users return to their intended destination after auth. - Updates the login page UI (hero carousel) and adds session-check redirect behavior.
- Updates the header to show Login vs. user avatar dropdown + Logout, and adjusts admin logout handling.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/pages/login/index.tsx | New login UI + session check + redirect target parsing. |
| src/pages/login/callback.tsx | Redirects to requested target after successful auth callback. |
| src/pages/admin/page.tsx | Redirects to /login on sign-out instead of clearing storage. |
| src/lib/utils.ts | Logout helper now only signs out (no global localStorage wipe). |
| src/lib/useAuthRole.ts | Exposes user in auth-role hook for header/profile rendering. |
| src/lib/supabase/actions/auth.actions.ts | Adds redirect parameter to Google OAuth callback URL. |
| src/components/layout/Header.tsx | Navbar now switches between Login and avatar/profile popover with Logout. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+17
to
+20
| const query = router.asPath.split("?")[1] ?? ""; | ||
| const redirectValue = new URLSearchParams(query).get("redirect") ?? "/"; | ||
| return redirectValue.startsWith("/") ? redirectValue : "/"; | ||
| }, [router.asPath, router.isReady]); |
Comment on lines
12
to
+29
| @@ -19,11 +21,12 @@ const AdminPage = () => { | |||
| } | |||
| client.auth.onAuthStateChange((event, session) => { | |||
| if (event === "SIGNED_OUT") { | |||
| localStorage.clear(); | |||
| setValidUser(false); | |||
| router.replace("/login"); | |||
| } | |||
| }) | |||
| checkSession(); | |||
| }, []); | |||
| }, [router]); | |||
…il.com are rejected, and login-related routes now fall back to / instead of looping back into the auth flow. The navbar Login button now sanitizes the current path before sending it into /login, and both the login page and callback use the same guard. I also fixed the admin auth listener so it unsubscribes on cleanup, preventing duplicate redirects after remounts or HMR. The shared sanitization lives in src/lib/utils.ts, and the route handling updates are in src/components/layout/Header.tsx, src/pages/login/index.tsx, src/pages/login/callback.tsx, and src/pages/admin/page.tsx.
BangKartavya
approved these changes
Aug 13, 2026
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.
PR: Add Login, Profile Avatar & Logout Flow
Changes
/login./after successful login./login.Flow
Logged out → Login button →
/loginSuccessful login → Redirect to
/→ User DP appearsClick DP → Profile dropdown → Logout
Logout → Session cleared → Redirect to
/login