From 16cef018b50d14e1c71f417a800c030374e2511e Mon Sep 17 00:00:00 2001 From: josedario87 Date: Sun, 5 Oct 2025 17:08:53 -0600 Subject: [PATCH] logout e integracion con authentik completa --- .mcp.json | 11 +- nuxt4-app/app/components/UserMenu.vue | 199 ++++++++++++++++-- nuxt4-app/app/components/app/AppSidebar.vue | 217 +++++++++++++++++--- nuxt4-app/app/composables/useAuth.ts | 14 +- nuxt4-app/app/error.vue | 82 ++++++++ nuxt4-app/app/pages/notifications.vue | 150 ++++++++++++++ nuxt4-app/app/pages/profile.vue | 93 +++++++++ nuxt4-app/app/pages/settings.vue | 120 +++++++++++ nuxt4-app/nuxt.config.ts | 4 + 9 files changed, 836 insertions(+), 54 deletions(-) create mode 100644 nuxt4-app/app/error.vue create mode 100644 nuxt4-app/app/pages/notifications.vue create mode 100644 nuxt4-app/app/pages/profile.vue create mode 100644 nuxt4-app/app/pages/settings.vue diff --git a/.mcp.json b/.mcp.json index 045baea..89ab984 100644 --- a/.mcp.json +++ b/.mcp.json @@ -2,7 +2,14 @@ "mcpServers": { "chrome-devtools": { "command": "npx", - "args": ["-y", "chrome-devtools-mcp@latest"] + "args": [ + "-y", + "chrome-devtools-mcp@latest" + ] + }, + "context7": { + "type": "http", + "url": "https://mcp.context7.com/mcp" } } -} +} \ No newline at end of file diff --git a/nuxt4-app/app/components/UserMenu.vue b/nuxt4-app/app/components/UserMenu.vue index 7500f92..1e030ce 100644 --- a/nuxt4-app/app/components/UserMenu.vue +++ b/nuxt4-app/app/components/UserMenu.vue @@ -1,21 +1,71 @@ @@ -23,26 +73,139 @@ const items = computed(() => [ diff --git a/nuxt4-app/app/components/app/AppSidebar.vue b/nuxt4-app/app/components/app/AppSidebar.vue index 7409786..adf410a 100644 --- a/nuxt4-app/app/components/app/AppSidebar.vue +++ b/nuxt4-app/app/components/app/AppSidebar.vue @@ -47,27 +47,182 @@ class="gap-1" /> - @@ -127,18 +282,16 @@ const navigationPrimary = computed(() => [ } ]) -const navigationSecondary: NavigationMenuItem[] = [ - { - label: 'Documentación', - icon: 'i-lucide-book-open', - to: 'https://ui.nuxt.com', - target: '_blank' - }, - { - label: 'Repositorio', - icon: 'i-lucide-github', - to: 'https://gitea.nucleoriofrio.com/nucleo000/analiticaNucleo', - target: '_blank' - } -] +const { user, loading, fetchUser, logout } = useAuth() + +// Cargar usuario al montar +onMounted(() => { + fetchUser() +}) + +// Computed para el avatar del usuario +const userAvatar = computed(() => ({ + src: user.value?.avatar_url || `https://ui-avatars.com/api/?name=${encodeURIComponent(user.value?.name || user.value?.username || 'User')}&background=3b82f6&color=fff&bold=true&format=svg`, + alt: user.value?.name || user.value?.username || 'User' +})) diff --git a/nuxt4-app/app/composables/useAuth.ts b/nuxt4-app/app/composables/useAuth.ts index 97e6ac3..a3e02ed 100644 --- a/nuxt4-app/app/composables/useAuth.ts +++ b/nuxt4-app/app/composables/useAuth.ts @@ -25,8 +25,18 @@ export const useAuth = () => { } const logout = () => { - // Authentik maneja el logout, redirigir a la URL de logout - window.location.href = '/outpost.goauthentik.io/sign_out' + // Limpiar estado local + user.value = null + loading.value = false + + // Obtener configuración de Authentik desde variables de entorno + const config = useRuntimeConfig() + const authentikUrl = config.public.authentikUrl || 'https://authentik.nucleoriofrio.com' + const appSlug = config.public.authentikAppSlug || 'devserver' + + // Redirigir al endpoint de logout de Authentik con el slug de la aplicación + // Esto cierra la sesión completa de Authentik (OIDC end-session) + window.location.href = `${authentikUrl}/application/o/${appSlug}/end-session/` } return { diff --git a/nuxt4-app/app/error.vue b/nuxt4-app/app/error.vue new file mode 100644 index 0000000..3e6a213 --- /dev/null +++ b/nuxt4-app/app/error.vue @@ -0,0 +1,82 @@ + + + diff --git a/nuxt4-app/app/pages/notifications.vue b/nuxt4-app/app/pages/notifications.vue new file mode 100644 index 0000000..f3a15bb --- /dev/null +++ b/nuxt4-app/app/pages/notifications.vue @@ -0,0 +1,150 @@ + + + diff --git a/nuxt4-app/app/pages/profile.vue b/nuxt4-app/app/pages/profile.vue new file mode 100644 index 0000000..b4999d6 --- /dev/null +++ b/nuxt4-app/app/pages/profile.vue @@ -0,0 +1,93 @@ + + + diff --git a/nuxt4-app/app/pages/settings.vue b/nuxt4-app/app/pages/settings.vue new file mode 100644 index 0000000..9daa28f --- /dev/null +++ b/nuxt4-app/app/pages/settings.vue @@ -0,0 +1,120 @@ + + + diff --git a/nuxt4-app/nuxt.config.ts b/nuxt4-app/nuxt.config.ts index 66132aa..1e49b58 100644 --- a/nuxt4-app/nuxt.config.ts +++ b/nuxt4-app/nuxt.config.ts @@ -164,6 +164,10 @@ export default defineNuxtConfig({ url: process.env.SUPABASE_URL || process.env.NEXT_PUBLIC_SUPABASE_URL, serviceRoleKey: process.env.SUPABASE_SERVICE_ROLE_KEY || process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY + }, + public: { + authentikUrl: process.env.NUXT_PUBLIC_AUTHENTIK_URL || '', + authentikAppSlug: process.env.NUXT_PUBLIC_AUTHENTIK_APP_SLUG || '' } } })