diff --git a/src/app/account/login/page.tsx b/src/app/account/login/page.tsx index 4d09057..6d54530 100644 --- a/src/app/account/login/page.tsx +++ b/src/app/account/login/page.tsx @@ -10,6 +10,7 @@ import Link from 'next/link' function AccountLoginForm ({ redirect }: { redirect: string | null }) { const [loading, setLoading] = useState(true) + const [alreadyLoggedIn, setAlreadyLoggedIn] = useState(false) const router = useRouter() const [username, setUsername] = useState('') @@ -20,8 +21,10 @@ function AccountLoginForm ({ redirect }: { redirect: string | null }) { const token = getCookie('accountToken', '-1') if (token !== '-1') { - router.push('/account') - } else setLoading(false) + document.title = 'Lncvrt Games - Account Login' + setAlreadyLoggedIn(true) + } + setLoading(false) }, [router]) return ( @@ -29,7 +32,9 @@ function AccountLoginForm ({ redirect }: { redirect: string | null }) {

- {loading ? 'Loading...' : 'Lncvrt Games Login'} + {loading + ? 'Loading...' + : `Lncvrt Games ${alreadyLoggedIn ? 'Refresh ' : ''}Login`}

{!loading && ( <> @@ -54,7 +59,9 @@ function AccountLoginForm ({ redirect }: { redirect: string | null }) { router.push(redirect ?? '/account') } else { alert( - 'Failed to login, error: ' + (result.data.message || 'n/a') + `Failed to ${ + alreadyLoggedIn ? 'refresh ' : '' + }login, error: ` + (result.data.message || 'n/a') ) } } catch (e: any) { @@ -65,9 +72,17 @@ function AccountLoginForm ({ redirect }: { redirect: string | null }) { JSON.stringify(e.response.data)) ) } else if (e.request) { - alert('Failed to login, no response from server.') + alert( + `Failed to ${ + alreadyLoggedIn ? 'refresh ' : '' + }login, no response from server.` + ) } else { - alert('Failed to login, error: ' + e.message) + alert( + `Failed to ${ + alreadyLoggedIn ? 'refresh ' : '' + }login, error: ` + e.message + ) } } }} @@ -92,12 +107,18 @@ function AccountLoginForm ({ redirect }: { redirect: string | null }) { /> -

+

-
+