Skip to content

Commit

Permalink
Merge pull request #9 from YoubetDao/feature/login
Browse files Browse the repository at this point in the history
fix: login
  • Loading branch information
wfnuser authored Jul 18, 2024
2 parents 80ae368 + 4b1be02 commit bdebcf4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
19 changes: 8 additions & 11 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { RainbowKitProvider, getDefaultConfig } from '@rainbow-me/rainbowkit'
import { WagmiProvider } from 'wagmi'
import '@rainbow-me/rainbowkit/styles.css'
import { scroll } from 'wagmi/chains'
import AuthProvider from './provider/auth-provider'
const config = getDefaultConfig({
appName: 'Kuibu',
projectId: '05c3ea68819376e65dc4a8802f90f41b',
Expand All @@ -18,15 +17,13 @@ const config = getDefaultConfig({
export default function App() {
const queryClient = useMemo(() => new QueryClient({}), [])
return (
<AuthProvider>
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<RainbowKitProvider>
<RouterProvider router={createRouter()} />
<ReactQueryDevtools />
</RainbowKitProvider>
</QueryClientProvider>
</WagmiProvider>
</AuthProvider>
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
<RainbowKitProvider>
<RouterProvider router={createRouter()} />
<ReactQueryDevtools />
</RainbowKitProvider>
</QueryClientProvider>
</WagmiProvider>
)
}
12 changes: 11 additions & 1 deletion src/pages/login/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import { Link } from 'react-router-dom'
import { Link, useNavigate } from 'react-router-dom'
import UserAuthForm from '@/components/forms/user-auth-form'
import { buttonVariants } from '@/components/ui/button'
import { cn } from '@/lib/utils'
import { useEffect } from 'react'
import Cookies from 'js-cookie'

export default function Login() {
const navigate = useNavigate()

useEffect(() => {
const token = Cookies.get('token')
if (token) {
navigate('/', { replace: true })
}
})
return (
<>
<div className="relative flex-col items-center justify-center h-screen md:grid lg:max-w-none lg:grid-cols-2 lg:px-0">
Expand Down
4 changes: 2 additions & 2 deletions src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { navItems } from '@/constants/data'
import { Pages } from '@/router/pages'
import { Layouts } from '@/router/layouts'
import { Helmet } from 'react-helmet'
import { useAuth } from '@/provider/auth-provider'
import Cookies from 'js-cookie'

const getDefaultLayout = ({ children }: { children: React.ReactNode }) => children

Expand All @@ -16,7 +16,7 @@ const routerObjects: RouteObject[] = navItems.map((item) => {
const isPrivate = item.component !== 'callback' && item.component !== 'login'

const Component = () => {
const { token } = useAuth()
const token = Cookies.get('token')
return (
<>
<Helmet>
Expand Down

0 comments on commit bdebcf4

Please sign in to comment.