2023-03-06 18:18:01 +11:00
|
|
|
import useSWR from 'swr'
|
|
|
|
import fetcher from './lib/fetcher'
|
|
|
|
import withBaseUrl from './lib/withBaseURL'
|
2023-06-22 16:43:33 +10:00
|
|
|
import { App } from './App'
|
2023-03-06 18:18:01 +11:00
|
|
|
|
|
|
|
export const Auth = () => {
|
2023-03-06 20:13:34 +11:00
|
|
|
const { data: user } = useSWR(withBaseUrl('/user'), fetcher) as any
|
2023-03-06 18:18:01 +11:00
|
|
|
const isLocalHost =
|
|
|
|
typeof window !== 'undefined' && window.location.hostname === 'localhost'
|
|
|
|
|
|
|
|
if (!user && !isLocalHost) {
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className=" bg-gray-800 p-1 px-4 rounded-r-lg pointer-events-auto flex items-center">
|
|
|
|
<a
|
|
|
|
className="font-bold mr-2 text-purple-400"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
target={'_self'}
|
|
|
|
href={`https://dev.kittycad.io/signin?callbackUrl=${encodeURIComponent(
|
|
|
|
typeof window !== 'undefined' && window.location.href
|
|
|
|
)}`}
|
|
|
|
>
|
|
|
|
Sign in
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
return <App />
|
|
|
|
}
|