The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
adds login screen scaffolds
Alaister Young287c05396da2
diff --git a/studio/components/interfaces/Login/ForgotPasswordForm.tsx b/studio/components/interfaces/Login/ForgotPasswordForm.tsxnew file mode 100644index 00000000000..becbd6b0f6a--- /dev/null+++ b/studio/components/interfaces/Login/ForgotPasswordForm.tsx@@ -0,0 +1,5 @@+const ForgotPasswordForm = () => {+ return <div></div>+}++export default ForgotPasswordFormdiff --git a/studio/components/interfaces/Login/LoginForm.tsx b/studio/components/interfaces/Login/LoginForm.tsxnew file mode 100644index 00000000000..c0af5e994d9--- /dev/null+++ b/studio/components/interfaces/Login/LoginForm.tsx@@ -0,0 +1,71 @@+import { auth } from 'lib/gotrue'+import Link from 'next/link'+import { Button, Form, Input } from 'ui'+import { object, string } from 'yup'++const loginSchema = object({+ email: string().email('Must be a valid email').required('Email is required'),+ password: string().required('Password is required'),+})++const LoginForm = () => {+ const onLogin = async ({ email, password }: { email: string; password: string }) => {+ const result = await auth.signInWithPassword({ email, password })+ console.log('result:', result)+ }++ return (+ <div>+ <h1>Login</h1>++ <Form+ validateOnBlur+ id="login-form"+ initialValues={{ email: '', password: '' }}+ validationSchema={loginSchema}+ onSubmit={onLogin}+ >+ {({ isSubmitting }: { isSubmitting: boolean }) => {+ return (+ <div className="mb-4 space-y-4 pt-4">+ <Input+ id="email"+ name="email"+ type="email"+ label="Email"+ placeholder="[email protected]"+ />++ <Input+ id="password"+ name="password"+ type="password"+ label="Password"+ placeholder="••••••••"+ />++ <div className="border-overlay-border border-t" />++ <Button+ block+ form="login-form"+ htmlType="submit"+ size="medium"+ disabled={isSubmitting}+ loading={isSubmitting}+ >+ Login+ </Button>+ </div>+ )+ }}+ </Form>++ <Link href="/forgot-password">+ <a>Forgot Password</a>+ </Link>+ </div>+ )+}++export default LoginFormdiff --git a/studio/components/interfaces/Login/LoginWithGitHub.tsx b/studio/components/interfaces/Login/LoginWithGitHub.tsxnew file mode 100644index 00000000000..2cf9cdf5760--- /dev/null+++ b/studio/components/interfaces/Login/LoginWithGitHub.tsx@@ -0,0 +1,26 @@+import { auth } from 'lib/gotrue'+import { Button, IconGitHub } from 'ui'++const LoginWithGitHub = () => {+ async function handleGithubSignIn() {+ try {+ const { error } = await auth.signInWithOAuth({+ provider: 'github',+ options: {+ redirectTo: `${process.env.NEXT_PUBLIC_SITE_URL}/projects?auth=true`,+ },+ })+ if (error) throw error+ } catch (error) {+ console.error(error)+ }+ }++ return (+ <Button onClick={handleGithubSignIn} icon={<IconGitHub />} size="medium">+ Continue with GitHub+ </Button>+ )+}++export default LoginWithGitHubdiff --git a/studio/components/interfaces/Login/RegisterForm.tsx b/studio/components/interfaces/Login/RegisterForm.tsxnew file mode 100644index 00000000000..bff2d69c502--- /dev/null+++ b/studio/components/interfaces/Login/RegisterForm.tsx@@ -0,0 +1,86 @@+import { auth } from 'lib/gotrue'+import Link from 'next/link'+import { Button, Form, IconLock, Input } from 'ui'+import { object, string } from 'yup'++const registerSchema = object({+ username: string()+ .max(39, 'Username is too long (maximum is 39 characters)')+ .matches(+ // Username regex is 'borrowed' from GitHub+ /^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i,+ 'Username may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen'+ )+ .required('Username is required'),+ email: string().email('Must be a valid email').required('Email is required'),+ password: string().required('Password is required'),+})++const RegisterForm = () => {+ const onRegister = async ({+ username,+ email,+ password,+ }: {+ username: string+ email: string+ password: string+ }) => {+ const result = await auth.signUp({ email, password, options: { data: { username } } })+ console.log('result:', result)+ }++ return (+ <Form+ validateOnBlur+ id="register-form"+ initialValues={{ email: '', password: '' }}+ validationSchema={registerSchema}+ onSubmit={onRegister}+ >+ {({ isSubmitting }: { isSubmitting: boolean }) => {+ return (+ <div className="flex flex-col gap-4">+ <Input+ id="username"+ name="username"+ type="text"+ label="Username"+ placeholder="your-username"+ />++ <Input+ id="email"+ name="email"+ type="email"+ label="Email"+ placeholder="[email protected]"+ />++ <Input+ id="password"+ name="password"+ type="password"+ label="Password"+ placeholder="••••••••"+ />++ <Button+ block+ form="register-form"+ htmlType="submit"+ size="medium"+ icon={<IconLock />}+ disabled={isSubmitting}+ loading={isSubmitting}+ >+ Register+ </Button>+ </div>+ )+ }}+ </Form>+ )+}++export default RegisterFormdiff --git a/studio/components/interfaces/Login/ResetPasswordForm.tsx b/studio/components/interfaces/Login/ResetPasswordForm.tsxnew file mode 100644index 00000000000..5b34602b0f5--- /dev/null+++ b/studio/components/interfaces/Login/ResetPasswordForm.tsx@@ -0,0 +1,5 @@+const ResetPasswordForm = () => {+ return <div></div>+}++export default ResetPasswordFormdiff --git a/studio/components/layouts/LoginLayout/LoginLayout.tsx b/studio/components/layouts/LoginLayout/LoginLayout.tsxnew file mode 100644index 00000000000..25f1cf7aa1d--- /dev/null+++ b/studio/components/layouts/LoginLayout/LoginLayout.tsx@@ -0,0 +1,82 @@+import { useStore } from 'hooks'+import { observer } from 'mobx-react-lite'+import Image from 'next/image'+import Link from 'next/link'+import { PropsWithChildren } from 'react'++type LoginLayoutProps = {+ title: string+ showDisclaimer?: boolean+}++const LoginLayout = ({+ title,+ showDisclaimer = true,+ children,+}: PropsWithChildren<LoginLayoutProps>) => {+ const {+ ui: { theme },+ } = useStore()++ return (+ <div className="flex flex-col gap-8 mb-5">+ <div className="sticky top-0 mx-auto w-full max-w-7xl px-8 pt-6 sm:px-6 lg:px-8">+ <nav className="relative flex items-center justify-between sm:h-10">+ <div className="flex flex-shrink-0 flex-grow items-center lg:flex-grow-0">+ <div className="flex w-full items-center justify-between md:w-auto">+ <a href="https://supabase.com">+ <Image+ src={theme == 'dark' ? '/img/supabase-dark.svg' : '/img/supabase-light.svg'}+ alt=""+ height={24}+ width={120}+ />+ </a>+ </div>+ </div>++ <div className="hidden items-center space-x-3 md:ml-10 md:flex md:pr-4">+ <a+ href="https://supabase.com/docs"+ className="text-sm text-scale-1100 transition-colors hover:text-scale-1200"+ >+ Documentation+ </a>+ </div>+ </nav>+ </div>++ <h1 className="text-2xl self-center mt-8">{title}</h1>++ <div className="flex flex-col justify-center items-center">+ <main className="min-w-[448px] flex flex-col bg-scale-400 px-5 rounded-lg shadow-lg">+ <img+ src="/supabase-logo.svg"+ alt="Supabase Logo"+ className="block w-20 mt-8 mb-10 self-center"+ />++ {children}+ </main>+ </div>++ {showDisclaimer && (+ <div className="sm:text-center">+ <p className="text-xs text-scale-900 sm:mx-auto sm:max-w-sm">+ By continuing, you agree to Supabase's{' '}+ <Link href="https://supabase.com/docs/company/terms">+ <a className="underline hover:text-scale-1100">Terms of Service</a>+ </Link>{' '}+ and{' '}+ <Link href="https://supabase.com/docs/company/privacy">+ <a className="underline hover:text-scale-1100">Privacy Policy</a>+ </Link>+ , and to receive periodic emails with updates.+ </p>+ </div>+ )}+ </div>+ )+}++export default observer(LoginLayout)diff --git a/studio/components/layouts/index.ts b/studio/components/layouts/index.tsindex a7cd8c77950..2457dda09a7 100644--- a/studio/components/layouts/index.ts+++ b/studio/components/layouts/index.ts@@ -13,6 +13,7 @@ import { WizardLayoutWithoutAuth } from './WizardLayout'import VercelIntegrationLayout from './VercelIntegrationLayout'import BillingLayout from './BillingLayout'import LogsExplorerLayout from './LogsExplorerLayout/LogsExplorerLayout'+import LoginLayout from './LoginLayout/LoginLayout'export {ProjectLayoutWithAuth,@@ -30,6 +31,7 @@ export {VercelIntegrationLayout,BillingLayout,LogsExplorerLayout,+ LoginLayout,}export default ProjectLayoutdiff --git a/studio/pages/forgot-password.tsx b/studio/pages/forgot-password.tsxnew file mode 100644index 00000000000..2be3114a874--- /dev/null+++ b/studio/pages/forgot-password.tsx@@ -0,0 +1,5 @@+const ForgotPasswordPage = () => {+ return <div></div>+}++export default ForgotPasswordPagediff --git a/studio/pages/index.tsx b/studio/pages/index.tsxindex c85615379e9..7599420efda 100644--- a/studio/pages/index.tsx+++ b/studio/pages/index.tsx@@ -1,50 +1,58 @@-import { useEffect } from 'react'import { observer } from 'mobx-react-lite'import { NextRouter, useRouter } from 'next/router'--import { NextPageWithLayout } from 'types'-import { useProfile, useStore, withAuth } from 'hooks'+import { useEffect } from 'react'+import { withAuth } from 'hooks'import { auth } from 'lib/gotrue'-import { IS_PLATFORM } from 'lib/constants'--import Connecting from 'components/ui/Loading'-import { AccountLayoutWithoutAuth } from 'components/layouts'+import { NextPageWithLayout } from 'types'import Landing from 'components/interfaces/Home/Landing'-import ProjectList from 'components/interfaces/Home/ProjectList'-import OrganizationDropdown from 'components/to-be-cleaned/Dropdown/OrganizationDropdown'--const Home: NextPageWithLayout = () => {- const { app } = useStore()+import LoginForm from 'components/interfaces/Login/LoginForm'+import LoginWithGitHub from 'components/interfaces/Login/LoginWithGitHub'+import { AccountLayoutWithoutAuth, LoginLayout } from 'components/layouts'+import Connecting from 'components/ui/Loading'+import Link from 'next/link'+const LoginPage: NextPageWithLayout = () => {return (<>- {app.organizations.isLoading ? (- <div className="flex h-full items-center justify-center space-x-2">- <Connecting />- </div>- ) : (- <div className="py-4 px-5">- {IS_PLATFORM && (- <div className="my-2">- <div className="flex">- <div className="">- <OrganizationDropdown organizations={app.organizations} />- </div>- </div>- </div>- )}- <div className="my-8 space-y-8">- <ProjectList />+ <div className="flex flex-col gap-4">+ <LoginWithGitHub />++ <div className="relative">+ <div className="absolute inset-0 flex items-center">+ <div className="w-full border-t border-scale-700" />+ </div>+ <div className="relative flex justify-center text-sm">+ <span className="bg-scale-400 px-2">Or</span></div></div>- )}++ <LoginForm />+ </div>++ <div className="w-full border-t border-scale-700 my-4" />++ <div className="mb-4">+ <div>+ <span className="text-scale-1000">Need an account?</span>{' '}+ <Link href="/register">+ <a className="underline hover:text-scale-1100">Register</a>+ </Link>+ </div>++ <div>+ <span className="text-scale-1000">Forgot your password?</span>{' '}+ <Link href="/forgot-password">+ <a className="underline hover:text-scale-1100">Reset Password</a>+ </Link>+ </div>+ </div></>)}-Home.getLayout = (page) => <IndexLayout>{page}</IndexLayout>+LoginPage.getLayout = (page) => <LoginLayout title="Login">{page}</LoginLayout>-export default observer(Home)+export default LoginPage// detect for redirect from 3rd party service like vercel, aws...const isRedirectFromThirdPartyService = (router: NextRouter) => router.query.next !== undefined@@ -73,37 +81,32 @@ const UnauthorizedLanding = () => {const IndexLayout = withAuth(observer(({ children }) => {const router = useRouter()- const { profile, isLoading } = useProfile()- if (isLoading) {- return <Connecting />- }+ // if (!profile) {+ // return <UnauthorizedLanding />+ // } else {+ // const isRedirect = isRedirectFromThirdPartyService(router)+ // if (isRedirect) {+ // const queryParams = (router.query as any) || {}+ // const params = new URLSearchParams(queryParams)+ // if (router.query?.next?.includes('https://vercel.com')) {+ // router.push(`/vercel/integrate?${params.toString()}`)+ // } else if (router.query?.next?.includes('new-project')) {+ // router.push('/new/project')+ // } else if (router.query?.next?.includes('join')) {+ // router.push(`/${router.query.next}`)+ // } else if (+ // typeof router.query?.next === 'string' &&+ // router.query?.next?.startsWith('project/_/')+ // ) {+ // router.push(router.query.next as string)+ // } else {+ // router.push('/')+ // }- if (!profile) {- return <UnauthorizedLanding />- } else {- const isRedirect = isRedirectFromThirdPartyService(router)- if (isRedirect) {- const queryParams = (router.query as any) || {}- const params = new URLSearchParams(queryParams)- if (router.query?.next?.includes('https://vercel.com')) {- router.push(`/vercel/integrate?${params.toString()}`)- } else if (router.query?.next?.includes('new-project')) {- router.push('/new/project')- } else if (router.query?.next?.includes('join')) {- router.push(`/${router.query.next}`)- } else if (- typeof router.query?.next === 'string' &&- router.query?.next?.startsWith('project/_/')- ) {- router.push(router.query.next as string)- } else {- router.push('/')- }-- return <Connecting />- }- }+ // return <Connecting />+ // }+ // }return (<AccountLayoutWithoutAuthdiff --git a/studio/pages/register.tsx b/studio/pages/register.tsxnew file mode 100644index 00000000000..87095b66d46--- /dev/null+++ b/studio/pages/register.tsx@@ -0,0 +1,39 @@+import LoginWithGitHub from 'components/interfaces/Login/LoginWithGitHub'+import RegisterForm from 'components/interfaces/Login/RegisterForm'+import { LoginLayout } from 'components/layouts'+import Link from 'next/link'+import { NextPageWithLayout } from 'types'++const RegisterPage: NextPageWithLayout = () => {+ return (+ <>+ <div className="flex flex-col gap-4">+ <LoginWithGitHub />++ <div className="relative">+ <div className="absolute inset-0 flex items-center">+ <div className="w-full border-t border-scale-700" />+ </div>+ <div className="relative flex justify-center text-sm">+ <span className="bg-scale-400 px-2">Or</span>+ </div>+ </div>++ <RegisterForm />+ </div>++ <div className="w-full border-t border-scale-700 my-4" />++ <div className="mb-4">+ <span className="text-scale-1000">Already have an account?</span>{' '}+ <Link href="/">+ <a className="underline hover:text-scale-1100">Login</a>+ </Link>+ </div>+ </>+ )+}++RegisterPage.getLayout = (page) => <LoginLayout title="Create a New Account">{page}</LoginLayout>++export default RegisterPagediff --git a/studio/pages/reset-password.tsx b/studio/pages/reset-password.tsxnew file mode 100644index 00000000000..80827264acf--- /dev/null+++ b/studio/pages/reset-password.tsx@@ -0,0 +1,5 @@+const ResetPasswordPage = () => {+ return <div></div>+}++export default ResetPasswordPage