SignInPartner.tsx55 lines · main
1import { Loader2 } from 'lucide-react'
2import { useRouter } from 'next/router'
3import { useEffect } from 'react'
4
5import { InlineLink } from '@/components/ui/InlineLink'
6import { auth } from '@/lib/gotrue'
7
8export const SignInPartner = () => {
9 const router = useRouter()
10
11 useEffect(() => {
12 ;(async () => {
13 const params = new URLSearchParams(window.location.hash.substring(1))
14
15 const partner = params.get('partner')
16 const token = params.get('id_token')
17
18 const { data } = await auth.getSession()
19
20 if (!data.session && partner && token) {
21 try {
22 await auth.signInWithIdToken({ provider: partner, token })
23 } finally {
24 router.replace({ pathname: '/sign-in-mfa' })
25 }
26 } else {
27 router.replace({ pathname: '/sign-in' })
28 }
29 })()
30 }, [])
31
32 return (
33 <div className="relative mx-auto w-full flex flex-col items-center justify-center gap-y-6">
34 <Loader2 className="animate-spin" />
35 <h2 className="text-lg text-center">Signing in to Briven Dashboard</h2>
36 <p className="text-xs text-foreground-lighter text-center max-w-[220px] sm:max-w-full">
37 By continuing, you agree to Briven’s{' '}
38 <InlineLink
39 href="https://supabase.com/terms"
40 className="text-foreground-lighter hover:text-foreground"
41 >
42 Terms of Service
43 </InlineLink>{' '}
44 and{' '}
45 <InlineLink
46 href="https://supabase.com/privacy"
47 className="text-foreground-lighter hover:text-foreground"
48 >
49 Privacy Policy
50 </InlineLink>
51 .
52 </p>
53 </div>
54 )
55}