Files
learn-languages/src/app/profile/page.tsx
2026-02-03 20:29:55 +08:00

17 lines
528 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { auth } from "@/auth";
import { redirect } from "next/navigation";
import { headers } from "next/headers";
export default async function ProfilePage() {
const session = await auth.api.getSession({ headers: await headers() });
if (!session) {
redirect("/auth?redirect=/profile");
}
// 已登录,跳转到用户资料页面
// 优先使用 username如果没有则使用 email
const username = (session.user.username as string) || (session.user.email as string);
redirect(`/users/${username}`);
}