Skip to content

Commit

Permalink
fix choose-username flow
Browse files Browse the repository at this point in the history
  • Loading branch information
berekuk committed Dec 6, 2024
1 parent 5c20608 commit 1971ff3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions packages/hub/src/app/settings/choose-username/page.tsx
Original file line number Diff line number Diff line change
@@ -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("/");
}

Expand Down

0 comments on commit 1971ff3

Please sign in to comment.