Files
seguidorDeLotes/nuxt4/app/components/auth/ActionButtons.vue
josedario87 a132fdfbf8 Add permanent 'Iniciar Sesión' button when not authenticated
Replace 'Ver Perfil' and 'Cerrar Sesión' buttons with a prominent
'Iniciar Sesión' button when user is not authenticated. The button
reloads the page to trigger Authentik login redirect.

This provides a more accessible way to log in compared to the toast
button, which can be difficult to click.

Button layout:
- Authenticated: [Estado de Sesión] [Ver Perfil] [Cerrar Sesión]
- Not authenticated: [Estado de Sesión] [Iniciar Sesión]
2025-10-13 01:56:42 -06:00

70 lines
1.7 KiB
Vue

<template>
<UCard class="w-full">
<div class="flex flex-wrap gap-3">
<!-- Botón de estado de sesión (siempre visible) -->
<UButton
color="info"
size="lg"
variant="soft"
@click="checkSessionStatus"
>
<template #leading>
<UIcon name="i-heroicons-information-circle" />
</template>
Estado de Sesión
</UButton>
<!-- Botones cuando HAY sesión -->
<template v-if="isAuthenticated">
<!-- Botón de perfil -->
<UButton
color="primary"
size="lg"
@click="goToProfile"
>
<template #leading>
<UIcon name="i-heroicons-user-circle" />
</template>
Ver Perfil
</UButton>
<!-- Botón de logout -->
<UButton
color="error"
size="lg"
variant="soft"
@click="logout"
>
<template #leading>
<UIcon name="i-heroicons-arrow-right-on-rectangle" />
</template>
Cerrar Sesión
</UButton>
</template>
<!-- Botón cuando NO hay sesión -->
<template v-else>
<UButton
color="primary"
size="lg"
@click="reloadPage"
>
<template #leading>
<UIcon name="i-heroicons-arrow-right-end-on-rectangle" />
</template>
Iniciar Sesión
</UButton>
</template>
</div>
</UCard>
</template>
<script setup lang="ts">
const { logout, goToProfile, checkSessionStatus, isAuthenticated } = useAuthentik()
const reloadPage = () => {
// Recargar la página para forzar redirect de Authentik al login
window.location.reload()
}
</script>