Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: hide sign in screen when not on platform (#10810)

Alaister Young43bce779cc39
diff --git a/studio/components/layouts/AccountLayout/AccountLayout.tsx b/studio/components/layouts/AccountLayout/AccountLayout.tsx
index 841e5794c5c..76cfacfab2e 100644
--- a/studio/components/layouts/AccountLayout/AccountLayout.tsx
+++ b/studio/components/layouts/AccountLayout/AccountLayout.tsx
@@ -108,18 +108,22 @@ const AccountLayout: FC<Props> = ({ children, title, breadcrumbs }) => {
},
],
},
- {
- key: 'logout-link',
- links: [
- {
- key: `logout`,
- icon: '/icons/feather/power.svg',
- label: 'Logout',
- href: undefined,
- onClick: onClickLogout,
- },
- ],
- },
+ ...(IS_PLATFORM
+ ? [
+ {
+ key: 'logout-link',
+ links: [
+ {
+ key: `logout`,
+ icon: '/icons/feather/power.svg',
+ label: 'Logout',
+ href: undefined,
+ onClick: onClickLogout,
+ },
+ ],
+ },
+ ]
+ : []),
]
return (
@@ -132,7 +136,7 @@ const AccountLayout: FC<Props> = ({ children, title, breadcrumbs }) => {
<div className="flex h-full">
<main
style={{ height: maxHeight, maxHeight }}
- className="flex w-full flex-1 flex-col overflow-y-auto"
+ className="flex flex-col flex-1 w-full overflow-y-auto"
>
<WithSidebar title={title} breadcrumbs={breadcrumbs} sections={sectionsWithHeaders}>
{children}
diff --git a/studio/components/layouts/SignInLayout/SignInLayout.tsx b/studio/components/layouts/SignInLayout/SignInLayout.tsx
index 1b520c22ce1..3bc77388456 100644
--- a/studio/components/layouts/SignInLayout/SignInLayout.tsx
+++ b/studio/components/layouts/SignInLayout/SignInLayout.tsx
@@ -1,5 +1,6 @@
import { useStore } from 'hooks'
import { usePushNext } from 'hooks/misc/useAutoAuthRedirect'
+import { IS_PLATFORM } from 'lib/constants'
import { auth, getReturnToPath, STORAGE_KEY } from 'lib/gotrue'
import { observer } from 'mobx-react-lite'
import Head from 'next/head'
@@ -77,19 +78,21 @@ const SignInLayout = ({
return (
<>
- <Head>
- <script
- dangerouslySetInnerHTML={{
- __html: `window._getReturnToPath = ${getReturnToPath.toString()};if (localStorage.getItem('${STORAGE_KEY}') && !(new URLSearchParams(location.search).has('next'))) {location.replace(window._getReturnToPath())}`,
- }}
- />
- </Head>
-
- <div className="flex-1 flex flex-col bg-scale-100">
- <div className="absolute top-0 mx-auto w-full px-8 pt-6 sm:px-6 lg:px-8">
+ {IS_PLATFORM && (
+ <Head>
+ <script
+ dangerouslySetInnerHTML={{
+ __html: `window._getReturnToPath = ${getReturnToPath.toString()};if (localStorage.getItem('${STORAGE_KEY}') && !(new URLSearchParams(location.search).has('next'))) {location.replace(window._getReturnToPath())}`,
+ }}
+ />
+ </Head>
+ )}
+
+ <div className="flex flex-col flex-1 bg-scale-100">
+ <div className="absolute top-0 w-full px-8 pt-6 mx-auto 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">
+ <div className="flex items-center flex-grow flex-shrink-0 lg:flex-grow-0">
+ <div className="flex items-center justify-between w-full md:w-auto">
<Link href={logoLinkToMarketingSite ? 'https://supabase.com' : '/projects'}>
<a>
<Image
@@ -103,7 +106,7 @@ const SignInLayout = ({
</div>
</div>
- <div className="hidden items-center space-x-3 md:ml-10 md:flex md:pr-4">
+ <div className="items-center hidden space-x-3 md:ml-10 md:flex md:pr-4">
<Link href="https://supabase.com/docs">
<a target="_blank">
<Button type="default" icon={<IconFileText />}>
@@ -115,12 +118,12 @@ const SignInLayout = ({
</nav>
</div>
- <div className="flex-1 flex">
- <main className="flex-1 flex-shrink-0 flex flex-col items-center bg-scale-200 px-5 pt-16 pb-8 border-r border-scale-500 shadow-lg">
+ <div className="flex flex-1">
+ <main className="flex flex-col items-center flex-1 flex-shrink-0 px-5 pt-16 pb-8 border-r shadow-lg bg-scale-200 border-scale-500">
<div className="flex-1 flex flex-col justify-center w-[384px]">
<div className="mb-10">
- <h1 className="text-2xl lg:text-3xl mt-8 mb-2">{heading}</h1>
- <h2 className="text-scale-1100 text-sm">{subheading}</h2>
+ <h1 className="mt-8 mb-2 text-2xl lg:text-3xl">{heading}</h1>
+ <h2 className="text-sm text-scale-1100">{subheading}</h2>
</div>
{children}
@@ -143,14 +146,14 @@ const SignInLayout = ({
)}
</main>
- <aside className="hidden flex-1 flex-shrink basis-1/4 xl:flex flex-col justify-center items-center">
+ <aside className="flex-col items-center justify-center flex-1 flex-shrink hidden basis-1/4 xl:flex">
{quote !== null && (
<div className="relative flex flex-col gap-6">
- <div className="absolute -top-12 -left-11 select-none">
+ <div className="absolute select-none -top-12 -left-11">
<span className="text-[160px] leading-none text-scale-600">{'“'}</span>
</div>
- <blockquote className="text-3xl z-10 max-w-lg">{quote.text}</blockquote>
+ <blockquote className="z-10 max-w-lg text-3xl">{quote.text}</blockquote>
<a
href={quote.url}
@@ -161,11 +164,11 @@ const SignInLayout = ({
<img
src={`https://supabase.com${quote.img_url}`}
alt={quote.handle}
- className="rounded-full w-12 h-12"
+ className="w-12 h-12 rounded-full"
/>
<div className="flex flex-col">
- <cite className="font-medium not-italic text-scale-1100 whitespace-nowrap">
+ <cite className="not-italic font-medium text-scale-1100 whitespace-nowrap">
@{quote.handle}
</cite>
</div>
diff --git a/studio/hooks/misc/withAuth.tsx b/studio/hooks/misc/withAuth.tsx
index bd0bfc2e287..202aad95343 100644
--- a/studio/hooks/misc/withAuth.tsx
+++ b/studio/hooks/misc/withAuth.tsx
@@ -84,11 +84,13 @@ export function withAuth<T>(
<Head>
{/* This script will quickly (before the main JS loads) redirect the user
to the login page if they are guaranteed (no token at all) to not be logged in. */}
- <script
- dangerouslySetInnerHTML={{
- __html: `window._getReturnToPath = ${getReturnToPath.toString()};if (!localStorage.getItem('${STORAGE_KEY}') && !location.hash) {const searchParams = new URLSearchParams(location.search);searchParams.set('returnTo', location.pathname);location.replace('/sign-in' + '?' + searchParams.toString())}`,
- }}
- />
+ {IS_PLATFORM && (
+ <script
+ dangerouslySetInnerHTML={{
+ __html: `window._getReturnToPath = ${getReturnToPath.toString()};if (!localStorage.getItem('${STORAGE_KEY}') && !location.hash) {const searchParams = new URLSearchParams(location.search);searchParams.set('returnTo', location.pathname);location.replace('/sign-in' + '?' + searchParams.toString())}`,
+ }}
+ />
+ )}
</Head>
<WrappedComponent {...props} />
</>
@@ -105,7 +107,7 @@ export function withAuth<T>(
}
function defaultRedirectTo(ref: string | string[] | undefined) {
- return IS_PLATFORM ? '/sign-in' : ref !== undefined ? `/project/${ref}` : '/sign-in'
+ return IS_PLATFORM ? '/sign-in' : ref !== undefined ? `/project/${ref}` : '/projects'
}
function checkRedirectTo(
diff --git a/studio/pages/sign-in.tsx b/studio/pages/sign-in.tsx
index 8080d2550e1..f6d811d6664 100644
--- a/studio/pages/sign-in.tsx
+++ b/studio/pages/sign-in.tsx
@@ -6,10 +6,21 @@ import SignInForm from 'components/interfaces/SignIn/SignInForm'
import SignInWithGitHub from 'components/interfaces/SignIn/SignInWithGitHub'
import SignInWithSSO from 'components/interfaces/SignIn/SignInWithSSO'
import { SignInLayout } from 'components/layouts'
+import { useEffect } from 'react'
+import { IS_PLATFORM } from 'lib/constants'
+import { useRouter } from 'next/router'
const SignInPage: NextPageWithLayout = () => {
const showSsoLogin = useFlag('mfaSso')
+ const router = useRouter()
+ useEffect(() => {
+ // if the dashboard is running locally, redirect straight to the projects page
+ if (!IS_PLATFORM) {
+ router.replace('/projects')
+ }
+ }, [])
+
return (
<>
<div className="flex flex-col gap-5">
@@ -21,18 +32,18 @@ const SignInPage: NextPageWithLayout = () => {
<div className="w-full border-t border-scale-700" />
</div>
<div className="relative flex justify-center text-sm">
- <span className="bg-scale-200 px-2 text-sm text-scale-1200">or</span>
+ <span className="px-2 text-sm bg-scale-200 text-scale-1200">or</span>
</div>
</div>
<SignInForm />
</div>
- <div className="my-8 self-center text-sm">
+ <div className="self-center my-8 text-sm">
<div>
<span className="text-scale-1000">Don't have an account?</span>{' '}
<Link href="/sign-up">
- <a className="underline text-scale-1200 hover:text-scale-1100 transition">
+ <a className="underline transition text-scale-1200 hover:text-scale-1100">
Sign Up Now
</a>
</Link>