SignInPartner.tsx 1.6 KB

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