From f91a7011ea506af6fd7e2fd9b9b3acfefff8a1b5 Mon Sep 17 00:00:00 2001 From: Nick Efe Oni Date: Mon, 30 Nov 2026 07:00:53 +0000 Subject: [PATCH 1/7] feat(login): enhance login form handling Updated the LoginClient component to improve form submission. Added type annotations for better TypeScript support and prevented default form submission behavior. This change enhances user experience by ensuring the form behaves correctly. --- app/login/LoginClient.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/login/LoginClient.tsx b/app/login/LoginClient.tsx index edbd4123..25b6c239 100644 --- a/app/login/LoginClient.tsx +++ b/app/login/LoginClient.tsx @@ -1,6 +1,6 @@ "use client"; -import { useState, useEffect, useRef } from "react"; +import { useState, useEffect, useRef, type FormEvent } from "react"; import { useRouter } from "next/navigation"; import Heading2 from "@/components/Heading2"; import TextField from "@/components/TextField"; @@ -46,7 +46,8 @@ export default function LoginClient() { const identifierError = touchedIdentifier ? getIdentifierError(identifier) : ""; const passwordError = touchedPassword ? getPasswordError(password) : ""; - const handleLogin = async () => { + const handleLogin = async (event: FormEvent) => { + event.preventDefault(); if (loading) return; setTouchedIdentifier(true); @@ -141,9 +142,11 @@ export default function LoginClient() { /> -
+
setTouchedIdentifier(true)} @@ -158,6 +161,8 @@ export default function LoginClient() { setTouchedPassword(true)} @@ -187,12 +192,12 @@ export default function LoginClient() { @@ -206,7 +211,7 @@ export default function LoginClient() { Create an account

-
+ ); From 5359d9c30d198b7e520fbe3fca3e7a70b297ea7e Mon Sep 17 00:00:00 2001 From: Nick Efe Oni Date: Mon, 30 Nov 2026 07:00:55 +0000 Subject: [PATCH 2/7] test(navbar-auth-state): update test case for sign out button Changed the test case to reference the SignOutButton component instead of NavBar. This ensures that the tests accurately reflect the current components in use. --- app/navbar-auth-state.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/navbar-auth-state.test.ts b/app/navbar-auth-state.test.ts index d1354d85..be34693e 100644 --- a/app/navbar-auth-state.test.ts +++ b/app/navbar-auth-state.test.ts @@ -28,7 +28,7 @@ describe("navbar authentication state", () => { }); it.each([ - "components/NavBar.tsx", + "components/SignOutButton.tsx", "components/AccountLifecycleStatus.tsx", "app/settings/account/AccountSettingsClient.tsx", "app/account-deletion/confirm/AccountDeletionConfirmationClient.tsx", From e5917c4c53942ee59375921d38148e3b80b415f7 Mon Sep 17 00:00:00 2001 From: Nick Efe Oni Date: Mon, 30 Nov 2026 07:00:57 +0000 Subject: [PATCH 3/7] feat(profile): add sign out button to account overview This update introduces a SignOutButton component to the account overview section. The button is conditionally rendered based on screen size to enhance user experience. --- app/profile/page.tsx | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/app/profile/page.tsx b/app/profile/page.tsx index e340c7d4..ea23b429 100644 --- a/app/profile/page.tsx +++ b/app/profile/page.tsx @@ -1,6 +1,7 @@ import Link from "next/link"; import { redirect } from "next/navigation"; import Image from "@/components/Image"; +import SignOutButton from "@/components/SignOutButton"; import StudyBuddyIcon, { type StudyBuddyIconName, } from "@/components/StudyBuddyIcon"; @@ -173,16 +174,21 @@ export default async function ProfilePage() {
-
-

- Account overview -

-

- The essentials for your current Study Buddy account. -

+
+
+

+ Account overview +

+

+ The essentials for your current Study Buddy account. +

+
+
+ +
From f243abfbc79b9ae608ad315cdeac3558a1d2614b Mon Sep 17 00:00:00 2001 From: Nick Efe Oni Date: Mon, 30 Nov 2026 07:00:59 +0000 Subject: [PATCH 4/7] refactor(NavBar): simplify logout handling Removed the manual logout handling from the NavBar component. Introduced a SignOutButton component to encapsulate the logout functionality. This change improves code readability and maintainability. --- components/NavBar.tsx | 42 +++++++----------------------------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/components/NavBar.tsx b/components/NavBar.tsx index 88a61057..00cde210 100644 --- a/components/NavBar.tsx +++ b/components/NavBar.tsx @@ -10,8 +10,8 @@ import { usePathname, useRouter } from "next/navigation"; import StudyBuddyIcon, { type StudyBuddyIconName, } from "./StudyBuddyIcon"; -import { useAuthState } from "./AuthStateProvider"; import NotificationBell from "./NotificationBell"; +import SignOutButton from "./SignOutButton"; interface NavLink { label: string; @@ -48,10 +48,8 @@ export default function NavBar({ }: Readonly) { const pathname = usePathname(); const router = useRouter(); - const { setIsAuthenticated } = useAuthState(); const [loadingLogin, setLoadingLogin] = useState(false); const [loadingSignup, setLoadingSignup] = useState(false); - const [loadingLogOut, setLoadingLogOut] = useState(false); const linkBase = "text-gray-700 hover:text-primary-500 font-medium transition-colors content-center"; @@ -59,25 +57,6 @@ export default function NavBar({ const linkActive = "text-primary-500 font-semibold bg-accent-100 px-3 py-1 rounded-lg"; - const handleLogout = async () => { - setLoadingLogOut(true); - try { - const response = await fetch("/api/v1/logout", { - method: "POST", - cache: "no-store", - }); - if (!response.ok) { - setLoadingLogOut(false); - return; - } - setIsAuthenticated(false); - router.replace("/login"); - router.refresh(); - } catch { - setLoadingLogOut(false); - } - }; - const handleLogin = () => { setLoadingLogin(true); router.push(signInLink ?? "/login"); @@ -134,6 +113,11 @@ export default function NavBar({
{isAuthenticated && showNotifications && } + {!isAuthenticated && pathname === "/" && ( + + )}
{!isAuthenticated && ( <> @@ -159,19 +143,7 @@ export default function NavBar({ )} - {isAuthenticated && ( - <> - - - )} + {isAuthenticated && }
From cb94fd0d0fb87907f599d9a40352e90fcac536eb Mon Sep 17 00:00:00 2001 From: Nick Efe Oni Date: Mon, 30 Nov 2026 07:01:00 +0000 Subject: [PATCH 5/7] feat(auth): add sign out button component This commit introduces a new SignOutButton component. The component handles user sign-out functionality, including error handling. It utilizes the useAuthState hook to manage authentication state. --- components/SignOutButton.tsx | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 components/SignOutButton.tsx diff --git a/components/SignOutButton.tsx b/components/SignOutButton.tsx new file mode 100644 index 00000000..7ff9d7da --- /dev/null +++ b/components/SignOutButton.tsx @@ -0,0 +1,52 @@ +"use client"; + +import { useId, useState } from "react"; +import { useRouter } from "next/navigation"; +import { useAuthState } from "./AuthStateProvider"; +import Button from "./Button"; +import FormErrorMessage from "./FormErrorMessage"; + +export default function SignOutButton() { + const router = useRouter(); + const { setIsAuthenticated } = useAuthState(); + const errorId = useId(); + const [loading, setLoading] = useState(false); + const [error, setError] = useState(""); + + async function handleSignOut() { + if (loading) return; + setLoading(true); + setError(""); + try { + const response = await fetch("/api/v1/logout", { + method: "POST", + cache: "no-store", + }); + if (!response.ok) throw new Error("Sign-out request failed."); + } catch { + setError("We couldn't log you out. Please try again."); + setLoading(false); + return; + } + + setIsAuthenticated(false); + router.replace("/login"); + router.refresh(); + } + + return ( +
+ + +
+ ); +} From c5ebee3b32a0dc11754d6b18b081ef6143bc31bf Mon Sep 17 00:00:00 2001 From: Nick Efe Oni Date: Mon, 30 Nov 2026 07:01:02 +0000 Subject: [PATCH 6/7] docs(website): update mobile login instructions Added a direct Log In link on the mobile homepage for easier access. Clarified that signed-in learners can log out from Profile on mobile or desktop. --- docs/WEBSITE_GUIDE.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/WEBSITE_GUIDE.md b/docs/WEBSITE_GUIDE.md index d9a7be15..eceb2069 100644 --- a/docs/WEBSITE_GUIDE.md +++ b/docs/WEBSITE_GUIDE.md @@ -46,6 +46,7 @@ cleanup; a source regression test guards ownership. This is not site-wide certif - [NavBar](../components/NavBar.tsx) shows desktop product links at **1110px and wider**. - Below 1110px, authenticated learners use the six-tab [BottomNav](../components/BottomNav.tsx): Home, Materials, Exams, Progress, Chat and Profile. Do not restore the legacy mobile menu. +- The mobile homepage offers a direct **Log In** link. Signed-in learners can use **Log Out** in Profile on mobile or in the header on desktop. - The approved profile SVG remains in both navigation variants. Settings is reached through Profile, not an extra bottom-nav tab. - [NotificationBell](../components/NotificationBell.tsx) preserves the existing bell and opens the inbox on mobile and desktop. Unknown counts must not be presented as zero. - The mobile bar includes the device safe area; the shell reserves footer clearance. @@ -144,6 +145,8 @@ guaranteed grades or licensed content solely because a route or illustration exi Login/signup use inline errors, not browser `alert()` popups. Account journeys include email verification, age/guardian decisions, password reset, security alert/recovery, deletion confirmation, deactivation and deletion-pending views. +The login form submits through the same validation when the learner presses +Enter or activates the **Log In** button. Provide distinct checking, incomplete-link, working, success and failure states. Never include a real recovery URL or token in screenshots or public examples. From 7b4fc7a35d19fd07ab4e28fd29c11b3fa5d33883 Mon Sep 17 00:00:00 2001 From: Nick Efe Oni Date: Mon, 30 Nov 2026 07:01:04 +0000 Subject: [PATCH 7/7] test(e2e): add mobile learner login and sign out tests This update introduces a new test for mobile learners. It verifies the login process, including error handling for invalid email. Additionally, it checks the sign-out functionality from the profile page. --- tests/e2e/account-lifecycle.spec.ts | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/e2e/account-lifecycle.spec.ts b/tests/e2e/account-lifecycle.spec.ts index b841dfe0..1d9dc3ad 100644 --- a/tests/e2e/account-lifecycle.spec.ts +++ b/tests/e2e/account-lifecycle.spec.ts @@ -150,6 +150,41 @@ test("sign-up checks age, verifies email once and signs out across tabs", async expect(await getUserId(page)).toBe(userId); }); +test("a mobile learner can reach login, submit with Enter and sign out from Profile", async ({ browser }) => { + const mobile = await browser.newContext({ + baseURL: APP_ORIGIN, viewport: { width: 320, height: 720 }, isMobile: true, hasTouch: true, + }); + try { + const page = await mobile.newPage(); + await page.goto("/"); + await page.getByRole("banner").getByRole("link", { name: "Log In", exact: true }).tap(); + await expect(page).toHaveURL(/\/login$/); + + const email = page.getByLabel(/Email or Phone Number/); + const password = page.getByLabel(/^Password/); + await email.fill("invalid"); + await password.fill(fixtureUsers.learner.password); + await password.press("Enter"); + await expect(page.getByText("Enter a valid email or phone number")).toBeVisible(); + await expect(page).toHaveURL(/\/login$/); + + await email.fill(fixtureUsers.learner.email); + await password.press("Enter"); + await expect(page).toHaveURL(/\/dashboard$/); + + await page.getByRole("navigation", { name: "Primary mobile navigation" }) + .getByRole("link", { name: "Profile", exact: true }).tap(); + await expect(page).toHaveURL(/\/profile$/); + await page.getByRole("main").getByRole("button", { name: "Log Out", exact: true }).tap(); + await expect(page).toHaveURL(/\/login$/); + expect((await page.request.get("/api/v1/me")).status()).toBe(401); + await page.goto("/dashboard"); + await expect(page).toHaveURL(/\/unauthorized$/); + } finally { + await mobile.close(); + } +}); + for (const approval of [true, false]) { test(`a guardian can ${approval ? "approve learning without AI" : "deny the account"}`, async ({ page, browser, request }) => { const variant = approval ? "approval" : "denial";