rough tauri auth (#167)

This commit is contained in:
Kurt Hutten
2023-07-11 20:34:09 +10:00
committed by GitHub
parent 4f8fe2d155
commit 317dc6d0b2
5 changed files with 66 additions and 11 deletions

View File

@ -2,12 +2,22 @@ import useSWR from 'swr'
import fetcher from './lib/fetcher'
import withBaseUrl from './lib/withBaseURL'
import { App } from './App'
import { SetToken } from './components/TokenInput'
import { useStore } from './useStore'
export const Auth = () => {
const { data: user } = useSWR(withBaseUrl('/user'), fetcher) as any
const {token} = useStore((s) => ({
token: s.token
}))
const isLocalHost =
typeof window !== 'undefined' && window.location.hostname === 'localhost'
if ((window as any).__TAURI__ && !token) {
return <SetToken />
}
if (!user && !isLocalHost) {
return (
<>