Redirect if not logged in
This commit is contained in:
@@ -3,15 +3,30 @@
|
|||||||
import { HomeButton } from '@/app/components/HomeButton'
|
import { HomeButton } from '@/app/components/HomeButton'
|
||||||
import { DiscordButton } from '@/app/components/DiscordButton'
|
import { DiscordButton } from '@/app/components/DiscordButton'
|
||||||
import { getCookie } from '@/util/cookie'
|
import { getCookie } from '@/util/cookie'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { useRouter } from 'next/navigation'
|
||||||
|
|
||||||
export default function AccountLoginPage () {
|
export default function AccountLoginPage () {
|
||||||
|
const [loading, setLoading] = useState<boolean>(true)
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const token = getCookie('accountToken', '-1')
|
||||||
|
if (token === '-1') {
|
||||||
|
router.push('/account/login')
|
||||||
|
} else setLoading(false)
|
||||||
|
}, [router])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='box'>
|
<div className='box'>
|
||||||
<HomeButton />
|
<HomeButton />
|
||||||
<DiscordButton />
|
<DiscordButton />
|
||||||
<p className={`px-8 -my-2 text-center`}>
|
<p className={`px-8 -my-2 text-center`}>
|
||||||
Nothing on this page yet! You are logged in as{' '}
|
{loading
|
||||||
{getCookie('accountUsername', 'N/A')}.
|
? 'Loading...'
|
||||||
|
: 'Nothing on this page yet! You are logged in as ' +
|
||||||
|
getCookie('accountUsername', 'N/A') +
|
||||||
|
'.'}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user