From 265104ff6784a6029a95ef4630e81b7cd32a960b Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Tue, 4 Mar 2025 11:59:33 -0700 Subject: [PATCH] move from hooks --- web/src/app/auth/reset-password-email/page.tsx | 2 +- web/src/app/auth/reset-password/page.tsx | 2 +- web/src/components/features/auth/LoginForm.tsx | 2 +- .../sidebars/SidebarUserFooter/SidebarUserFooter.tsx | 2 +- web/src/layouts/AppAssetCheckLayout.tsx | 2 +- .../supabaseAuthMethods/index.ts | 0 .../supabaseAuthMethods/resetPassword.ts | 0 .../supabaseAuthMethods/signIn.ts | 0 .../supabaseAuthMethods/signOut.tsx | 11 +---------- 9 files changed, 6 insertions(+), 15 deletions(-) rename web/src/{hooks => server_context}/supabaseAuthMethods/index.ts (100%) rename web/src/{hooks => server_context}/supabaseAuthMethods/resetPassword.ts (100%) rename web/src/{hooks => server_context}/supabaseAuthMethods/signIn.ts (100%) rename web/src/{hooks => server_context}/supabaseAuthMethods/signOut.tsx (63%) diff --git a/web/src/app/auth/reset-password-email/page.tsx b/web/src/app/auth/reset-password-email/page.tsx index c74198b22..df762f86b 100644 --- a/web/src/app/auth/reset-password-email/page.tsx +++ b/web/src/app/auth/reset-password-email/page.tsx @@ -1,5 +1,5 @@ import { ResetEmailForm } from '@/components/features/auth/ResetEmailForm'; -import { resetPasswordEmailSend } from '@/hooks/supabaseAuthMethods'; +import { resetPasswordEmailSend } from '@/server_context/supabaseAuthMethods'; import React from 'react'; export default function ResetPassword(p: { searchParams: { email: string } }) { diff --git a/web/src/app/auth/reset-password/page.tsx b/web/src/app/auth/reset-password/page.tsx index 1632d6902..9e2076057 100644 --- a/web/src/app/auth/reset-password/page.tsx +++ b/web/src/app/auth/reset-password/page.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { resetPassword } from '@/hooks/supabaseAuthMethods'; +import { resetPassword } from '@/server_context/supabaseAuthMethods'; import { redirect } from 'next/navigation'; import { BusterRoutes, createBusterRoute } from '@/routes/busterRoutes'; import { useSupabaseServerContext } from '@/context/Supabase/useSupabaseContext'; diff --git a/web/src/components/features/auth/LoginForm.tsx b/web/src/components/features/auth/LoginForm.tsx index 2064ce94b..3d062ac69 100644 --- a/web/src/components/features/auth/LoginForm.tsx +++ b/web/src/components/features/auth/LoginForm.tsx @@ -20,7 +20,7 @@ import { signInWithGithub, signInWithGoogle, signUp -} from '@/hooks/supabaseAuthMethods'; +} from '@/server_context/supabaseAuthMethods'; import { StatusCard } from '@/components/ui/card/StatusCard'; import { SuccessCard } from '@/components/ui/card/SuccessCard'; diff --git a/web/src/components/features/sidebars/SidebarUserFooter/SidebarUserFooter.tsx b/web/src/components/features/sidebars/SidebarUserFooter/SidebarUserFooter.tsx index 7a6cc6191..3a3b422d2 100644 --- a/web/src/components/features/sidebars/SidebarUserFooter/SidebarUserFooter.tsx +++ b/web/src/components/features/sidebars/SidebarUserFooter/SidebarUserFooter.tsx @@ -15,7 +15,7 @@ import { BUSTER_DOCS_URL } from '@/routes/externalRoutes'; import { type DropdownProps, Dropdown } from '@/components/ui/dropdown/Dropdown'; import { AvatarUserButton } from '@/components/ui/avatar/AvatarUserButton'; import { useUserConfigContextSelector } from '@/context/Users'; -import { signOut } from '@/hooks/supabaseAuthMethods'; +import { signOut } from '@/server_context/supabaseAuthMethods'; export const SidebarUserFooter: React.FC<{}> = () => { const user = useUserConfigContextSelector((x) => x.user); diff --git a/web/src/layouts/AppAssetCheckLayout.tsx b/web/src/layouts/AppAssetCheckLayout.tsx index 3d2508bb7..a464c482b 100644 --- a/web/src/layouts/AppAssetCheckLayout.tsx +++ b/web/src/layouts/AppAssetCheckLayout.tsx @@ -7,7 +7,7 @@ import { redirect } from 'next/navigation'; import { BusterRoutes, createBusterRoute } from '@/routes'; import { AppPasswordAccess } from '@controllers/AppPasswordAccess'; import { AppNoPageAccess } from '@controllers/AppNoPageAccess'; -import { signInWithAnonymousUser } from '@/hooks/supabaseAuthMethods'; +import { signInWithAnonymousUser } from '@/server_context/supabaseAuthMethods'; export type AppAssetCheckLayoutProps = { metricId?: string; diff --git a/web/src/hooks/supabaseAuthMethods/index.ts b/web/src/server_context/supabaseAuthMethods/index.ts similarity index 100% rename from web/src/hooks/supabaseAuthMethods/index.ts rename to web/src/server_context/supabaseAuthMethods/index.ts diff --git a/web/src/hooks/supabaseAuthMethods/resetPassword.ts b/web/src/server_context/supabaseAuthMethods/resetPassword.ts similarity index 100% rename from web/src/hooks/supabaseAuthMethods/resetPassword.ts rename to web/src/server_context/supabaseAuthMethods/resetPassword.ts diff --git a/web/src/hooks/supabaseAuthMethods/signIn.ts b/web/src/server_context/supabaseAuthMethods/signIn.ts similarity index 100% rename from web/src/hooks/supabaseAuthMethods/signIn.ts rename to web/src/server_context/supabaseAuthMethods/signIn.ts diff --git a/web/src/hooks/supabaseAuthMethods/signOut.tsx b/web/src/server_context/supabaseAuthMethods/signOut.tsx similarity index 63% rename from web/src/hooks/supabaseAuthMethods/signOut.tsx rename to web/src/server_context/supabaseAuthMethods/signOut.tsx index 0b6fc0ddd..389797b64 100644 --- a/web/src/hooks/supabaseAuthMethods/signOut.tsx +++ b/web/src/server_context/supabaseAuthMethods/signOut.tsx @@ -3,12 +3,10 @@ import { createClient } from '@/context/Supabase/server'; import { redirect } from 'next/navigation'; import { BusterRoutes, createBusterRoute } from '@/routes/busterRoutes/busterRoutes'; -import Cookies from 'js-cookie'; -import { QueryClient } from '@tanstack/react-query'; export const signOut = async () => { + 'use server'; const supabase = await createClient(); - const queryClient = new QueryClient(); const { error } = await supabase.auth.signOut(); @@ -16,13 +14,6 @@ export const signOut = async () => { return { error: error.message }; } - setTimeout(() => { - Object.keys(Cookies.get()).forEach((cookieName) => { - Cookies.remove(cookieName); - }); - queryClient.clear(); - }, 650); - return redirect( createBusterRoute({ route: BusterRoutes.AUTH_LOGIN