diff --git a/app/pages/Login.vue b/app/pages/Login.vue index 2754dfb..3d6993a 100644 --- a/app/pages/Login.vue +++ b/app/pages/Login.vue @@ -124,15 +124,10 @@ const passwordRules = [ ]; const login = async () => { - loading.value = true; - await signIn({ username: "admin", password: "admin" }); - - setTimeout(() => { - loading.value = false; - // Redirigir al dashboard después del login - console.log("signIn", signIn); - router.push("/"); - }, 2000); + await signIn( + { username: "admin", password: "admin" }, + { callbackUrl: "/" }, + ); }; diff --git a/app/pages/index.vue b/app/pages/index.vue index 893fcce..c58e639 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -13,6 +13,7 @@
{{ data }} + {{ status }}
@@ -24,7 +25,7 @@ definePageMeta({ import { ref, onMounted } from "vue"; import { useChuckNorris } from "~/stores/chuck"; const norrisStore = useChuckNorris(); -const { data } = useAuth(); +const { data, status } = useAuth(); onMounted(async () => { await norrisStore.getData(); diff --git a/nuxt.config.ts b/nuxt.config.ts index 8a61b79..a82eee2 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -8,10 +8,21 @@ export default defineNuxtConfig({ baseURL: "http://localhost:3000", }, auth: { - globalAppMiddleware: false, + globalAppMiddleware: true, baseURL: "http://localhost:8000/auth", provider: { type: "local", + refresh: { + isEnabled: true, + endpoint: { path: "/refresh", method: "post" }, + refreshOnlyToken: true, + token: { + signInResponseRefreshTokenPointer: "/refresh", + refreshResponseTokenPointer: "", + refreshRequestTokenPointer: "/refresh", + maxAgeInSeconds: 60 * 60 * 24, + }, + }, endpoints: { signIn: { path: "/jwt/create/", method: "post" }, signOut: false, @@ -25,6 +36,7 @@ export default defineNuxtConfig({ signInResponseTokenPointer: "/access", type: "JWT", headerName: "Authorization", + maxAgeInSeconds: 60 * 30, }, sessionDataType: {}, },