Skip to content

Commit 159ede2

Browse files
hfjoshenlim
andauthored
feat: add sign-in-partner page (supabase#37699)
* feat: add sign-in-partner page * Update sign in partner page --------- Co-authored-by: Joshen Lim <[email protected]>
1 parent 7b1ac2a commit 159ede2

File tree

5 files changed

+95
-13
lines changed

5 files changed

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

apps/studio/components/layouts/SignInLayout/ForgotPasswordLayout.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@ import { useTheme } from 'next-themes'
33
import Image from 'next/legacy/image'
44
import Link from 'next/link'
55
import { PropsWithChildren } from 'react'
6+
import { cn } from 'ui'
67

78
type ForgotPasswordLayoutProps = {
8-
heading: string
9-
subheading: string
9+
heading?: string
10+
subheading?: string
1011
logoLinkToMarketingSite?: boolean
1112
showHeadings?: boolean
13+
className?: string
1214
}
1315

1416
const ForgotPasswordLayout = ({
1517
heading,
1618
subheading,
1719
logoLinkToMarketingSite = false,
1820
showHeadings = true,
21+
className,
1922
children,
2023
}: PropsWithChildren<ForgotPasswordLayoutProps>) => {
2124
const { resolvedTheme } = useTheme()
2225

2326
return (
24-
<div className="min-h-screen flex-1 bg-studio flex flex-col gap-8 lg:gap-16 xl:gap-32">
27+
<div
28+
className={cn(
29+
'min-h-screen flex-1 bg-studio flex flex-col gap-8 lg:gap-16 xl:gap-32',
30+
className
31+
)}
32+
>
2533
<div className="sticky top-0 mx-auto w-full max-w-7xl px-8 pt-6 sm:px-6 lg:px-8">
2634
<nav className="relative flex items-center justify-between sm:h-10">
2735
<div className="flex flex-shrink-0 flex-grow items-center lg:flex-grow-0">

apps/studio/pages/reset-password.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import Link from 'next/link'
2-
31
import ResetPasswordForm from 'components/interfaces/SignIn/ResetPasswordForm'
42
import ForgotPasswordLayout from 'components/layouts/SignInLayout/ForgotPasswordLayout'
53
import { withAuth } from 'hooks/misc/withAuth'
64
import type { NextPageWithLayout } from 'types'
75

86
const ResetPasswordPage: NextPageWithLayout = () => {
97
return (
10-
<>
11-
<div className="flex flex-col gap-4">
12-
<ResetPasswordForm />
13-
</div>
14-
</>
8+
<div className="flex flex-col gap-4">
9+
<ResetPasswordForm />
10+
</div>
1511
)
1612
}
1713

apps/studio/pages/sign-in-fly-tos.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useEffect, useState } from 'react'
77
import { useIsLoggedIn } from 'common'
88
import { useOrganizationByFlyOrgIdMutation } from 'data/organizations/organization-by-fly-organization-id-mutation'
99
import { useProjectByFlyExtensionIdMutation } from 'data/projects/project-by-fly-extension-id-mutation'
10-
import { API_URL } from 'lib/constants'
10+
import { API_URL, BASE_PATH } from 'lib/constants'
1111
import { Button } from 'ui'
1212

1313
const SignInFlyTos = () => {
@@ -78,8 +78,8 @@ const SignInFlyTos = () => {
7878
<Image
7979
src={
8080
resolvedTheme?.includes('dark')
81-
? `${router.basePath}/img/supabase-dark.svg`
82-
: `${router.basePath}/img/supabase-light.svg`
81+
? `${BASE_PATH}/img/supabase-dark.svg`
82+
: `${BASE_PATH}/img/supabase-light.svg`
8383
}
8484
alt=""
8585
height={24}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { SignInPartner } from 'components/interfaces/SignIn/SignInPartner'
2+
import ForgotPasswordLayout from 'components/layouts/SignInLayout/ForgotPasswordLayout'
3+
import type { NextPageWithLayout } from 'types'
4+
import { cn } from 'ui'
5+
6+
const SignInPartnerPage: NextPageWithLayout = () => {
7+
return <SignInPartner />
8+
}
9+
10+
SignInPartnerPage.getLayout = (page) => (
11+
// [Joshen] Just using this layout for the styling
12+
<ForgotPasswordLayout
13+
showHeadings={false}
14+
className={cn(
15+
'mx-auto max-w-7xl px-8 sm:px-12 lg:px-16 !gap-y-0',
16+
'[&>div:first-child]:absolute [&>div:first-child]:!px-0',
17+
'[&>div:last-child]:flex-grow [&>div:last-child>main]:!px-0'
18+
)}
19+
>
20+
{page}
21+
</ForgotPasswordLayout>
22+
)
23+
24+
export default SignInPartnerPage

0 commit comments

Comments
 (0)