Skip to content

login feature changes - #41

Merged
ShreyasVij merged 2 commits into
masterfrom
login
Aug 13, 2026
Merged

ShreyasVij merged 2 commits into
masterfrom
login

Conversation

@ShreyasVij

Copy link
Copy Markdown
Collaborator

PR: Add Login, Profile Avatar & Logout Flow

Changes

  • Added Login button to the navbar for unauthenticated users.
  • Added redirect to /login.
  • Added automatic redirect to / after successful login.
  • Display the authenticated user's Google profile picture in the navbar.
  • Added a profile dropdown that opens when the user clicks their DP.
  • Added user name/email information inside the dropdown.
  • Added Logout functionality inside the profile dropdown.
  • Logout clears the session and redirects the user to /login.
  • Navbar dynamically updates based on the user's authentication state.
  • Added fallback avatar handling when a profile picture is unavailable.
  • Ensured the authentication state persists across navigation and page refreshes.
  • Kept the implementation responsive and consistent with the existing navbar design.

Flow

Logged out → Login button → /login

Successful login → Redirect to / → User DP appears

Click DP → Profile dropdown → Logout

Logout → Session cleared → Redirect to /login

Copilot AI lite review requested due to automatic review settings August 13, 2026 10:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 redirect propagation through /login and /login/callback so 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 thread src/pages/login/index.tsx Outdated
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 thread src/lib/supabase/actions/auth.actions.ts
Comment thread src/components/layout/Header.tsx Outdated
Comment thread src/pages/admin/page.tsx
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.
@ShreyasVij
ShreyasVij merged commit 46f0315 into master Aug 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants