Files
myeasycms-v2/apps/web/app/update-password/page.tsx
giancarlo 2b0fbc445b Refactor authentication method to requireUser
Replaced the requireAuth method with requireUser to improve clarity and modified all instances where it was used. Renamed the import throughout multiple files and services and made changes accordingly, thus making it more specific and understandable that a logged-in user is needed. The return type of the method was also updated from Session to User to more accurately reflect the information it provides.
2024-03-29 15:52:32 +08:00

29 lines
891 B
TypeScript

import { redirect } from 'next/navigation';
import { PasswordResetForm } from '@kit/auth/password-reset';
import { AuthLayoutShell } from '@kit/auth/shared';
import { requireUser } from '@kit/supabase/require-user';
import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client';
import { AppLogo } from '~/components/app-logo';
import pathsConfig from '~/config/paths.config';
import { withI18n } from '~/lib/i18n/with-i18n';
async function PasswordResetPage() {
const client = getSupabaseServerComponentClient();
const auth = await requireUser(client);
// we require the user to be logged in to access this page
if (auth.error) {
redirect(auth.redirectTo);
}
return (
<AuthLayoutShell Logo={AppLogo}>
<PasswordResetForm redirectTo={pathsConfig.app.home} />
</AuthLayoutShell>
);
}
export default withI18n(PasswordResetPage);