Add auth redirect for logged-in users on login/register pages
- Check for authentication token on page load - If user is already logged in, redirect to dashboard - Prevents logged-in users from seeing login/register forms - Applies to both login.html and register.html
This commit is contained in:
@@ -264,6 +264,15 @@
|
||||
|
||||
|
||||
<!-- Scripts -->
|
||||
<script>
|
||||
// Check if user is already logged in and redirect
|
||||
(function() {
|
||||
const token = localStorage.getItem('edh-stats-token') || sessionStorage.getItem('edh-stats-token')
|
||||
if (token) {
|
||||
window.location.href = '/dashboard.html'
|
||||
}
|
||||
})()
|
||||
</script>
|
||||
<script
|
||||
defer
|
||||
src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"
|
||||
|
||||
@@ -712,12 +712,21 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script
|
||||
defer
|
||||
src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"
|
||||
></script>
|
||||
<script src="/js/auth.js"></script>
|
||||
<!-- Scripts -->
|
||||
<script>
|
||||
// Check if user is already logged in and redirect
|
||||
(function() {
|
||||
const token = localStorage.getItem('edh-stats-token') || sessionStorage.getItem('edh-stats-token')
|
||||
if (token) {
|
||||
window.location.href = '/dashboard.html'
|
||||
}
|
||||
})()
|
||||
</script>
|
||||
<script
|
||||
defer
|
||||
src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js"
|
||||
></script>
|
||||
<script src="/js/auth.js"></script>
|
||||
|
||||
<script src="/js/footer-loader.js"></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user