Redirect if not logged in

This commit is contained in:
2026-01-30 18:53:40 -07:00
parent 9474dd7baa
commit 567dd14858

View File

@@ -3,15 +3,30 @@
import { HomeButton } from '@/app/components/HomeButton'
import { DiscordButton } from '@/app/components/DiscordButton'
import { getCookie } from '@/util/cookie'
import { useEffect, useState } from 'react'
import { useRouter } from 'next/navigation'
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 (
<div className='box'>
<HomeButton />
<DiscordButton />
<p className={`px-8 -my-2 text-center`}>
Nothing on this page yet! You are logged in as{' '}
{getCookie('accountUsername', 'N/A')}.
{loading
? 'Loading...'
: 'Nothing on this page yet! You are logged in as ' +
getCookie('accountUsername', 'N/A') +
'.'}
</p>
</div>
)