Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
farnoux committed Feb 10, 2025
1 parent 258d99a commit 7df01f8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 48 deletions.
5 changes: 5 additions & 0 deletions packages/auth/app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createClient } from '@/api/utils/supabase/server-client';
import { LoginPageClient } from './page.client';

/**
Expand All @@ -19,6 +20,10 @@ export default async function LoginPage({
}) {
const { view, email, otp, redirect_to } = await searchParams;

// Log out to clear old auth cookie
const supabase = await createClient();
await supabase.auth.signOut();

return (
<LoginPageClient
view={view}
Expand Down
56 changes: 28 additions & 28 deletions packages/auth/src/supabase/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,34 @@ export async function updateSessionOrRedirect(request: NextRequest) {

// For all other cases → redirect to the app

if (url.hostname.endsWith('.territoiresentransitions.fr')) {
const cookiesToDelete = request.cookies
.getAll()
.filter(
(cookie) =>
cookie.name.startsWith('sb-') && !cookie.name.startsWith('sb-tet')
);

if (cookiesToDelete.length > 0) {
cookiesToDelete.forEach((cookie) => {
// supabaseResponse.cookies.delete({
// name: cookie.name,
// domain: `.${url.hostname}`,
// });

supabaseResponse.cookies.set(cookie.name, cookie.value, {
domain: `.${getRootDomain(url.hostname)}`,
path: '/',
// expires: new Date(0),
maxAge: 100000000,
secure: process.env.NODE_ENV === 'production',
sameSite: 'lax',
});
});

// return supabaseResponse;
}
}
// if (url.hostname.endsWith('.territoiresentransitions.fr')) {
// const cookiesToDelete = request.cookies
// .getAll()
// .filter(
// (cookie) =>
// cookie.name.startsWith('sb-') && !cookie.name.startsWith('sb-tet')
// );

// if (cookiesToDelete.length > 0) {
// cookiesToDelete.forEach((cookie) => {
// // supabaseResponse.cookies.delete({
// // name: cookie.name,
// // domain: `.${url.hostname}`,
// // });

// supabaseResponse.cookies.set(cookie.name, cookie.value, {
// domain: `.${getRootDomain(url.hostname)}`,
// path: '/',
// // expires: new Date(0),
// maxAge: 100000000,
// secure: process.env.NODE_ENV === 'production',
// sameSite: 'lax',
// });
// });

// // return supabaseResponse;
// }
// }

const searchParams = url.searchParams;
const redirectTo = searchParams.get('redirect_to');
Expand Down
20 changes: 0 additions & 20 deletions packages/auth/src/supabase/server.ts

This file was deleted.

0 comments on commit 7df01f8

Please sign in to comment.