- Incremented version in package.json from 2.12.1 to 2.12.2. - Updated the UpdatePasswordPage component to utilize the new requireUser function for improved user session handling. - Refactored requireUser function to include a next parameter for redirecting after authentication failures, enhancing user experience. - Introduced a helper function getRedirectTo for cleaner redirect logic.
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { redirect } from 'next/navigation';
|
|
|
|
import { UpdatePasswordForm } from '@kit/auth/password-reset';
|
|
import { AuthLayoutShell } from '@kit/auth/shared';
|
|
import { requireUser } from '@kit/supabase/require-user';
|
|
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
|
|
|
import { AppLogo } from '~/components/app-logo';
|
|
import pathsConfig from '~/config/paths.config';
|
|
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
|
import { withI18n } from '~/lib/i18n/with-i18n';
|
|
|
|
export const generateMetadata = async () => {
|
|
const { t } = await createI18nServerInstance();
|
|
|
|
return {
|
|
title: t('auth:updatePassword'),
|
|
};
|
|
};
|
|
|
|
const Logo = () => <AppLogo href={''} />;
|
|
|
|
interface UpdatePasswordPageProps {
|
|
searchParams: Promise<{
|
|
callback?: string;
|
|
}>;
|
|
}
|
|
|
|
async function UpdatePasswordPage(props: UpdatePasswordPageProps) {
|
|
const client = getSupabaseServerClient();
|
|
|
|
const result = await requireUser(client, {
|
|
next: pathsConfig.auth.passwordUpdate,
|
|
});
|
|
|
|
if (result.error) {
|
|
return redirect(result.redirectTo);
|
|
}
|
|
|
|
const { callback } = await props.searchParams;
|
|
const redirectTo = callback ?? pathsConfig.app.home;
|
|
|
|
return (
|
|
<AuthLayoutShell Logo={Logo}>
|
|
<UpdatePasswordForm redirectTo={redirectTo} />
|
|
</AuthLayoutShell>
|
|
);
|
|
}
|
|
|
|
export default withI18n(UpdatePasswordPage);
|