chore(version): bump version to 2.12.2 and refactor password update logic

- 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.
This commit is contained in:
gbuomprisco
2025-07-22 21:10:00 +02:00
parent 7e0c196adc
commit 0b53644dd9
3 changed files with 24 additions and 5 deletions

View File

@@ -1,11 +1,14 @@
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';
import { requireUserInServerComponent } from '~/lib/server/require-user-in-server-component';
export const generateMetadata = async () => {
const { t } = await createI18nServerInstance();
@@ -24,7 +27,15 @@ interface UpdatePasswordPageProps {
}
async function UpdatePasswordPage(props: UpdatePasswordPageProps) {
await requireUserInServerComponent();
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;