diff --git a/packages/hub/src/app/settings/choose-username/ChooseUsername.tsx b/packages/hub/src/app/settings/choose-username/ChooseUsername.tsx index 08c8b7fb83..fa6b349293 100644 --- a/packages/hub/src/app/settings/choose-username/ChooseUsername.tsx +++ b/packages/hub/src/app/settings/choose-username/ChooseUsername.tsx @@ -22,7 +22,8 @@ export const ChooseUsername: FC = () => { >({ action: setUsernameAction, onSuccess: () => { - router.replace("/"); + // this is enough - `page.tsx` will notice that the username is set now, and redirect to the home page + router.refresh(); }, formDataToInput: (data) => ({ username: data.username }), blockOnSuccess: true, diff --git a/packages/hub/src/app/settings/choose-username/page.tsx b/packages/hub/src/app/settings/choose-username/page.tsx index 54359fa4a4..9d8b2b930e 100644 --- a/packages/hub/src/app/settings/choose-username/page.tsx +++ b/packages/hub/src/app/settings/choose-username/page.tsx @@ -1,13 +1,13 @@ import { Metadata } from "next"; import { redirect } from "next/navigation"; -import { getSessionUserOrRedirect } from "@/users/auth"; +import { auth } from "@/lib/server/auth"; import { ChooseUsername } from "./ChooseUsername"; export default async function OuterChooseUsernamePage() { - const sessionUser = await getSessionUserOrRedirect(); - if (sessionUser.username) { + const session = await auth(); + if (!session?.user.email || session.user.username) { redirect("/"); }