una-nuxt-module 3.0.34 → 3.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "una-nuxt-module",
3
- "version": "3.0.34",
3
+ "version": "3.0.35",
4
4
  "configKey": "unaxt",
5
5
  "compatibility": {
6
6
  "nuxt": ">=4.0.0"
package/dist/module.mjs CHANGED
@@ -167,7 +167,7 @@ function addTemplates() {
167
167
  }
168
168
 
169
169
  const name = "una-nuxt-module";
170
- const version = "3.0.34";
170
+ const version = "3.0.35";
171
171
 
172
172
  const module$1 = defineNuxtModule({
173
173
  meta: {
@@ -1,6 +1,7 @@
1
- import { computed, ref, useNuxtApp } from "#imports";
1
+ import { computed, ref, useNuxtApp, useRuntimeConfig } from "#imports";
2
2
  import { defineStore } from "pinia";
3
3
  import { EAuthorization } from "../../enums/EAuthorization.js";
4
+ const LOGOUT_ENDPOINT = "/api/usuario/logout";
4
5
  export const useAuthStore = defineStore("AuthStore", () => {
5
6
  const user = ref(null);
6
7
  const authData = ref(null);
@@ -10,29 +11,45 @@ export const useAuthStore = defineStore("AuthStore", () => {
10
11
  const token = computed(() => authData.value?.accessToken ?? null);
11
12
  const logout = async () => {
12
13
  const { $signOut } = useNuxtApp();
13
- await $signOut();
14
+ const runtimeConfig = useRuntimeConfig();
15
+ const baseURL = runtimeConfig.public.apiBaseUrl;
16
+ try {
17
+ await $fetch(LOGOUT_ENDPOINT, {
18
+ baseURL,
19
+ method: "DELETE",
20
+ headers: {
21
+ Authorization: `Bearer ${token.value}`
22
+ }
23
+ });
24
+ } catch (error) {
25
+ console.error("Error en logout:", error);
26
+ } finally {
27
+ await $signOut();
28
+ }
14
29
  };
15
30
  const update = (userInfo, data) => {
16
31
  user.value = userInfo;
17
32
  authData.value = data;
18
33
  };
19
34
  const hasResource = (resource) => {
20
- return !!authData.value?.resources?.find((r) => r.nombre === resource);
35
+ return authData.value?.resources?.some(
36
+ (currentResource) => currentResource.nombre === resource
37
+ ) ?? false;
21
38
  };
22
39
  const hasAuthorizationInResource = ({
23
40
  resource,
24
41
  authorization
25
42
  }) => {
26
43
  const resourceData = authData.value?.resources.find(
27
- (r) => r.nombre === resource
44
+ (currentResource) => currentResource.nombre === resource
28
45
  );
29
46
  if (!resourceData) return false;
30
- const permissions = /* @__PURE__ */ new Map([
31
- [EAuthorization.CREATE, resourceData.permisoInsertar],
32
- [EAuthorization.EDIT, resourceData.permisoModificar],
33
- [EAuthorization.DELETE, resourceData.permisoEliminar]
34
- ]);
35
- return permissions.get(authorization) ?? false;
47
+ const permissions = {
48
+ [EAuthorization.CREATE]: resourceData.permisoInsertar,
49
+ [EAuthorization.EDIT]: resourceData.permisoModificar,
50
+ [EAuthorization.DELETE]: resourceData.permisoEliminar
51
+ };
52
+ return permissions[authorization] ?? false;
36
53
  };
37
54
  return {
38
55
  user,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "una-nuxt-module",
3
- "version": "3.0.34",
3
+ "version": "3.0.35",
4
4
  "description": "Módulo Nuxt para desarrollo CGI",
5
5
  "repository": {
6
6
  "type": "git",