una-nuxt-module 2.0.0 → 2.0.2
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.d.mts +1 -3
- package/dist/module.d.ts +1 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/layout/header/BtnExtendMenu.vue +1 -1
- package/dist/runtime/components/layout/sidebar/SideBar.vue +2 -2
- package/dist/runtime/components/layout/sidebar/SideBarFooter.vue +1 -1
- package/dist/runtime/components/layout/sidebar/TopSideBarLogo.vue +1 -1
- package/dist/runtime/composables/useTableState.d.ts +1 -1
- package/dist/runtime/plugins/auth.js +0 -4
- package/dist/runtime/stores/UiCustomizer.d.ts +22 -36
- package/dist/runtime/stores/UiCustomizer.js +22 -45
- package/dist/runtime/stores/auth.d.ts +131 -77
- package/dist/runtime/stores/auth.js +44 -66
- package/dist/runtime/types/index.d.ts +0 -35
- package/package.json +20 -20
- package/dist/runtime/utils/stringToBoolean.d.ts +0 -11
- package/dist/runtime/utils/stringToBoolean.js +0 -4
package/dist/module.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { IUnaNuxtModuleOptions } from '../dist/runtime/types/index.js';
|
|
5
3
|
|
|
6
4
|
declare const _default: _nuxt_schema.NuxtModule<IUnaNuxtModuleOptions, IUnaNuxtModuleOptions, false>;
|
|
7
5
|
|
package/dist/module.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { IUnaNuxtModuleOptions } from '../dist/runtime/types/index.js';
|
|
5
3
|
|
|
6
4
|
declare const _default: _nuxt_schema.NuxtModule<IUnaNuxtModuleOptions, IUnaNuxtModuleOptions, false>;
|
|
7
5
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { createResolver, defineNuxtModule, useLogger, extendPages, addLayout, ad
|
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
|
|
4
4
|
const name = "una-nuxt-module";
|
|
5
|
-
const version = "2.0.
|
|
5
|
+
const version = "2.0.2";
|
|
6
6
|
|
|
7
7
|
function resolve(path) {
|
|
8
8
|
const resolver = createResolver(import.meta.url);
|
|
@@ -16,7 +16,7 @@ import { useUiCustomizerStore } from "../../../stores/UiCustomizer";
|
|
|
16
16
|
const uiCustomizer = useUiCustomizerStore();
|
|
17
17
|
|
|
18
18
|
const extendMenuIcon = computed(() => {
|
|
19
|
-
return uiCustomizer.
|
|
19
|
+
return uiCustomizer.isSidebarMinimized ? "mdi-menu-close" : "mdi-menu-open";
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
const handleClick = () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
3
|
<v-navigation-drawer
|
|
4
|
-
:rail="uiCustomizer.
|
|
4
|
+
:rail="uiCustomizer.isSidebarMinimized"
|
|
5
5
|
@mouseleave="isHoveringSideBar = false"
|
|
6
6
|
@mouseover="isHoveringSideBar = true"
|
|
7
7
|
app
|
|
@@ -68,7 +68,7 @@ const menuItems = shallowRef(authorization.getAuthorizedPaths());
|
|
|
68
68
|
|
|
69
69
|
const uiCustomizerRef = storeToRefs(uiCustomizer);
|
|
70
70
|
|
|
71
|
-
watch(uiCustomizerRef.
|
|
71
|
+
watch(uiCustomizerRef.isSidebarMinimized, (newValue, oldValue) => {
|
|
72
72
|
if (newValue) openedMenus.value = [];
|
|
73
73
|
});
|
|
74
74
|
</script>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="d-flex justify-center">
|
|
3
3
|
<NuxtLink to="/" style="text-decoration: none; color: inherit">
|
|
4
4
|
<img
|
|
5
|
-
v-if="!uiCustomizer.
|
|
5
|
+
v-if="!uiCustomizer.isSidebarMinimized || openSidebar"
|
|
6
6
|
alt=""
|
|
7
7
|
height="40"
|
|
8
8
|
src="/images/logos/UNA_LogoType_LogoMark_Red.png"
|
|
@@ -10,7 +10,7 @@ interface IUseCrudStateParams {
|
|
|
10
10
|
export declare const useTableState: (params: IUseCrudStateParams) => {
|
|
11
11
|
pagination: import("vue").ComputedRef<{
|
|
12
12
|
page: number;
|
|
13
|
-
size:
|
|
13
|
+
size: any;
|
|
14
14
|
}>;
|
|
15
15
|
resetTableStatus: () => void;
|
|
16
16
|
updatePagination: (params: {
|
|
@@ -4,14 +4,10 @@ import {
|
|
|
4
4
|
Hooks
|
|
5
5
|
} from "@asgardeo/auth-spa";
|
|
6
6
|
import { useAuthorization, useAuthStore } from "#imports";
|
|
7
|
-
import stringToBoolean from "../utils/stringToBoolean.js";
|
|
8
7
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
9
8
|
const auth = AsgardeoSPAClient.getInstance();
|
|
10
9
|
const runtimeConfig = useRuntimeConfig();
|
|
11
10
|
const config = runtimeConfig.public.unaNuxtModule.sso;
|
|
12
|
-
if (typeof config.validateIDToken === "string") {
|
|
13
|
-
config.validateIDToken = stringToBoolean(config.validateIDToken);
|
|
14
|
-
}
|
|
15
11
|
auth?.initialize(config);
|
|
16
12
|
auth?.signIn();
|
|
17
13
|
auth?.on(Hooks.SignIn, async (response) => {
|
|
@@ -1,40 +1,26 @@
|
|
|
1
1
|
import { ETheme } from "../enums/index.js";
|
|
2
|
-
import type { IUiCustomizerState } from "../types/index.js";
|
|
3
2
|
/**
|
|
4
3
|
* Store encargado de almacenar y gestionar las preferencias visuales del usuario.
|
|
5
4
|
*/
|
|
6
|
-
export declare const useUiCustomizerStore: import("pinia").StoreDefinition<"UiCustomizerStore",
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Cambia el estado de la barra lateral a minimizado o expandido.
|
|
30
|
-
*
|
|
31
|
-
* @param newValue
|
|
32
|
-
*/
|
|
33
|
-
setSidebarMini(newValue: boolean): void;
|
|
34
|
-
/**
|
|
35
|
-
* Cambia el tema de la aplicación.
|
|
36
|
-
*
|
|
37
|
-
* @param newTheme - Nuevo tema de la aplicación
|
|
38
|
-
*/
|
|
39
|
-
setTheme(newTheme: ETheme): void;
|
|
40
|
-
}>;
|
|
5
|
+
export declare const useUiCustomizerStore: import("pinia").StoreDefinition<"UiCustomizerStore", Pick<{
|
|
6
|
+
drawSidebar: import("vue").Ref<boolean, boolean>;
|
|
7
|
+
isSidebarMinimized: import("vue").Ref<boolean, boolean>;
|
|
8
|
+
currentTheme: import("vue").Ref<"dark" | "light", "dark" | "light">;
|
|
9
|
+
toggleSidebar: () => void;
|
|
10
|
+
setSidebarMini: (newValue: boolean) => void;
|
|
11
|
+
setTheme: (newTheme: ETheme) => void;
|
|
12
|
+
}, "drawSidebar" | "isSidebarMinimized" | "currentTheme">, Pick<{
|
|
13
|
+
drawSidebar: import("vue").Ref<boolean, boolean>;
|
|
14
|
+
isSidebarMinimized: import("vue").Ref<boolean, boolean>;
|
|
15
|
+
currentTheme: import("vue").Ref<"dark" | "light", "dark" | "light">;
|
|
16
|
+
toggleSidebar: () => void;
|
|
17
|
+
setSidebarMini: (newValue: boolean) => void;
|
|
18
|
+
setTheme: (newTheme: ETheme) => void;
|
|
19
|
+
}, never>, Pick<{
|
|
20
|
+
drawSidebar: import("vue").Ref<boolean, boolean>;
|
|
21
|
+
isSidebarMinimized: import("vue").Ref<boolean, boolean>;
|
|
22
|
+
currentTheme: import("vue").Ref<"dark" | "light", "dark" | "light">;
|
|
23
|
+
toggleSidebar: () => void;
|
|
24
|
+
setSidebarMini: (newValue: boolean) => void;
|
|
25
|
+
setTheme: (newTheme: ETheme) => void;
|
|
26
|
+
}, "toggleSidebar" | "setSidebarMini" | "setTheme">>;
|
|
@@ -1,48 +1,25 @@
|
|
|
1
1
|
import { defineStore } from "pinia";
|
|
2
2
|
import { ETheme } from "../enums/index.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Alterna el estado de renderizar el menú de la barra lateral.
|
|
27
|
-
*/
|
|
28
|
-
toggleSidebar() {
|
|
29
|
-
this.drawSidebar = !this.drawSidebar;
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* Cambia el estado de la barra lateral a minimizado o expandido.
|
|
33
|
-
*
|
|
34
|
-
* @param newValue
|
|
35
|
-
*/
|
|
36
|
-
setSidebarMini(newValue) {
|
|
37
|
-
this.isSidebarMini = newValue;
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* Cambia el tema de la aplicación.
|
|
41
|
-
*
|
|
42
|
-
* @param newTheme - Nuevo tema de la aplicación
|
|
43
|
-
*/
|
|
44
|
-
setTheme(newTheme) {
|
|
45
|
-
this.currentTheme = newTheme;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
3
|
+
import { ref } from "#imports";
|
|
4
|
+
export const useUiCustomizerStore = defineStore("UiCustomizerStore", () => {
|
|
5
|
+
const drawSidebar = ref(true);
|
|
6
|
+
const isSidebarMinimized = ref(false);
|
|
7
|
+
const currentTheme = ref(ETheme.LIGHT);
|
|
8
|
+
const toggleSidebar = () => {
|
|
9
|
+
drawSidebar.value = !drawSidebar.value;
|
|
10
|
+
};
|
|
11
|
+
const setSidebarMini = (newValue) => {
|
|
12
|
+
isSidebarMinimized.value = newValue;
|
|
13
|
+
};
|
|
14
|
+
const setTheme = (newTheme) => {
|
|
15
|
+
currentTheme.value = newTheme;
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
drawSidebar,
|
|
19
|
+
isSidebarMinimized,
|
|
20
|
+
currentTheme,
|
|
21
|
+
toggleSidebar,
|
|
22
|
+
setSidebarMini,
|
|
23
|
+
setTheme
|
|
24
|
+
};
|
|
48
25
|
});
|
|
@@ -1,80 +1,134 @@
|
|
|
1
|
-
import type { IAuthData, IAuthenticatedUser,
|
|
1
|
+
import type { IAuthData, IAuthenticatedUser, IHasAuthorizationInResourceParams } from "../types/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Store encargado de almacenar y gestionar la autenticación y autorización del usuario.
|
|
4
4
|
*/
|
|
5
|
-
export declare const useAuthStore: import("pinia").StoreDefinition<"AuthStore",
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
5
|
+
export declare const useAuthStore: import("pinia").StoreDefinition<"AuthStore", Pick<{
|
|
6
|
+
user: import("vue").Ref<{
|
|
7
|
+
email: string;
|
|
8
|
+
fullName: string;
|
|
9
|
+
name?: string | undefined;
|
|
10
|
+
lastName?: string | undefined;
|
|
11
|
+
photoUrl?: string | undefined;
|
|
12
|
+
mainRole?: string | undefined;
|
|
13
|
+
} | null, IAuthenticatedUser | {
|
|
14
|
+
email: string;
|
|
15
|
+
fullName: string;
|
|
16
|
+
name?: string | undefined;
|
|
17
|
+
lastName?: string | undefined;
|
|
18
|
+
photoUrl?: string | undefined;
|
|
19
|
+
mainRole?: string | undefined;
|
|
20
|
+
} | null>;
|
|
21
|
+
authData: import("vue").Ref<{
|
|
22
|
+
isAuthenticated: boolean;
|
|
23
|
+
accessToken: string;
|
|
24
|
+
resources: {
|
|
25
|
+
id: number;
|
|
26
|
+
nombre: string;
|
|
27
|
+
permisoInsertar: boolean;
|
|
28
|
+
permisoModificar: boolean;
|
|
29
|
+
permisoEliminar: boolean;
|
|
30
|
+
}[];
|
|
31
|
+
} | null, IAuthData | {
|
|
32
|
+
isAuthenticated: boolean;
|
|
33
|
+
accessToken: string;
|
|
34
|
+
resources: {
|
|
35
|
+
id: number;
|
|
36
|
+
nombre: string;
|
|
37
|
+
permisoInsertar: boolean;
|
|
38
|
+
permisoModificar: boolean;
|
|
39
|
+
permisoEliminar: boolean;
|
|
40
|
+
}[];
|
|
41
|
+
} | null>;
|
|
42
|
+
isAuthenticated: import("vue").ComputedRef<boolean>;
|
|
43
|
+
token: import("vue").ComputedRef<string | null>;
|
|
44
|
+
logout: () => Promise<void>;
|
|
45
|
+
update: (userInfo: IAuthenticatedUser, data: IAuthData) => void;
|
|
46
|
+
hasResource: (resource: string) => boolean;
|
|
47
|
+
hasAuthorizationInResource: ({ resource, authorization, }: IHasAuthorizationInResourceParams) => boolean;
|
|
48
|
+
}, "user" | "authData">, Pick<{
|
|
49
|
+
user: import("vue").Ref<{
|
|
50
|
+
email: string;
|
|
51
|
+
fullName: string;
|
|
52
|
+
name?: string | undefined;
|
|
53
|
+
lastName?: string | undefined;
|
|
54
|
+
photoUrl?: string | undefined;
|
|
55
|
+
mainRole?: string | undefined;
|
|
56
|
+
} | null, IAuthenticatedUser | {
|
|
57
|
+
email: string;
|
|
58
|
+
fullName: string;
|
|
59
|
+
name?: string | undefined;
|
|
60
|
+
lastName?: string | undefined;
|
|
61
|
+
photoUrl?: string | undefined;
|
|
62
|
+
mainRole?: string | undefined;
|
|
63
|
+
} | null>;
|
|
64
|
+
authData: import("vue").Ref<{
|
|
65
|
+
isAuthenticated: boolean;
|
|
66
|
+
accessToken: string;
|
|
67
|
+
resources: {
|
|
68
|
+
id: number;
|
|
69
|
+
nombre: string;
|
|
70
|
+
permisoInsertar: boolean;
|
|
71
|
+
permisoModificar: boolean;
|
|
72
|
+
permisoEliminar: boolean;
|
|
73
|
+
}[];
|
|
74
|
+
} | null, IAuthData | {
|
|
75
|
+
isAuthenticated: boolean;
|
|
76
|
+
accessToken: string;
|
|
77
|
+
resources: {
|
|
78
|
+
id: number;
|
|
79
|
+
nombre: string;
|
|
80
|
+
permisoInsertar: boolean;
|
|
81
|
+
permisoModificar: boolean;
|
|
82
|
+
permisoEliminar: boolean;
|
|
83
|
+
}[];
|
|
84
|
+
} | null>;
|
|
85
|
+
isAuthenticated: import("vue").ComputedRef<boolean>;
|
|
86
|
+
token: import("vue").ComputedRef<string | null>;
|
|
87
|
+
logout: () => Promise<void>;
|
|
88
|
+
update: (userInfo: IAuthenticatedUser, data: IAuthData) => void;
|
|
89
|
+
hasResource: (resource: string) => boolean;
|
|
90
|
+
hasAuthorizationInResource: ({ resource, authorization, }: IHasAuthorizationInResourceParams) => boolean;
|
|
91
|
+
}, "isAuthenticated" | "token">, Pick<{
|
|
92
|
+
user: import("vue").Ref<{
|
|
93
|
+
email: string;
|
|
94
|
+
fullName: string;
|
|
95
|
+
name?: string | undefined;
|
|
96
|
+
lastName?: string | undefined;
|
|
97
|
+
photoUrl?: string | undefined;
|
|
98
|
+
mainRole?: string | undefined;
|
|
99
|
+
} | null, IAuthenticatedUser | {
|
|
100
|
+
email: string;
|
|
101
|
+
fullName: string;
|
|
102
|
+
name?: string | undefined;
|
|
103
|
+
lastName?: string | undefined;
|
|
104
|
+
photoUrl?: string | undefined;
|
|
105
|
+
mainRole?: string | undefined;
|
|
106
|
+
} | null>;
|
|
107
|
+
authData: import("vue").Ref<{
|
|
108
|
+
isAuthenticated: boolean;
|
|
109
|
+
accessToken: string;
|
|
110
|
+
resources: {
|
|
111
|
+
id: number;
|
|
112
|
+
nombre: string;
|
|
113
|
+
permisoInsertar: boolean;
|
|
114
|
+
permisoModificar: boolean;
|
|
115
|
+
permisoEliminar: boolean;
|
|
116
|
+
}[];
|
|
117
|
+
} | null, IAuthData | {
|
|
118
|
+
isAuthenticated: boolean;
|
|
119
|
+
accessToken: string;
|
|
120
|
+
resources: {
|
|
121
|
+
id: number;
|
|
122
|
+
nombre: string;
|
|
123
|
+
permisoInsertar: boolean;
|
|
124
|
+
permisoModificar: boolean;
|
|
125
|
+
permisoEliminar: boolean;
|
|
126
|
+
}[];
|
|
127
|
+
} | null>;
|
|
128
|
+
isAuthenticated: import("vue").ComputedRef<boolean>;
|
|
129
|
+
token: import("vue").ComputedRef<string | null>;
|
|
130
|
+
logout: () => Promise<void>;
|
|
131
|
+
update: (userInfo: IAuthenticatedUser, data: IAuthData) => void;
|
|
132
|
+
hasResource: (resource: string) => boolean;
|
|
133
|
+
hasAuthorizationInResource: ({ resource, authorization, }: IHasAuthorizationInResourceParams) => boolean;
|
|
134
|
+
}, "logout" | "update" | "hasResource" | "hasAuthorizationInResource">>;
|
|
@@ -1,69 +1,47 @@
|
|
|
1
1
|
import { defineStore } from "pinia";
|
|
2
2
|
import { EAuthorization } from "../enums/EAuthorization.js";
|
|
3
|
-
import { useNuxtApp } from "#
|
|
4
|
-
export const useAuthStore = defineStore({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
authData
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
hasResource
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Verifica si el usuario tiene la autorización sobre un recurso.
|
|
49
|
-
*
|
|
50
|
-
* @param params - Objeto con los parámetros de recurso y autorización.
|
|
51
|
-
* @returns
|
|
52
|
-
*/
|
|
53
|
-
hasAuthorizationInResource({
|
|
54
|
-
resource,
|
|
55
|
-
authorization
|
|
56
|
-
}) {
|
|
57
|
-
const resourceData = this.authData?.resources.find(
|
|
58
|
-
(r) => r.nombre === resource
|
|
59
|
-
);
|
|
60
|
-
if (!resourceData) return false;
|
|
61
|
-
const permissions = /* @__PURE__ */ new Map([
|
|
62
|
-
[EAuthorization.CREATE, resourceData.permisoInsertar],
|
|
63
|
-
[EAuthorization.EDIT, resourceData.permisoModificar],
|
|
64
|
-
[EAuthorization.DELETE, resourceData.permisoEliminar]
|
|
65
|
-
]);
|
|
66
|
-
return permissions.get(authorization) ?? false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
3
|
+
import { computed, ref, useNuxtApp } from "#imports";
|
|
4
|
+
export const useAuthStore = defineStore("AuthStore", () => {
|
|
5
|
+
const user = ref(null);
|
|
6
|
+
const authData = ref(null);
|
|
7
|
+
const isAuthenticated = computed(
|
|
8
|
+
() => authData.value?.isAuthenticated ?? false
|
|
9
|
+
);
|
|
10
|
+
const token = computed(() => authData.value?.accessToken ?? null);
|
|
11
|
+
const logout = async () => {
|
|
12
|
+
const { $signOut } = useNuxtApp();
|
|
13
|
+
await $signOut();
|
|
14
|
+
};
|
|
15
|
+
const update = (userInfo, data) => {
|
|
16
|
+
user.value = userInfo;
|
|
17
|
+
authData.value = data;
|
|
18
|
+
};
|
|
19
|
+
const hasResource = (resource) => {
|
|
20
|
+
return !!authData.value?.resources?.find((r) => r.nombre === resource);
|
|
21
|
+
};
|
|
22
|
+
const hasAuthorizationInResource = ({
|
|
23
|
+
resource,
|
|
24
|
+
authorization
|
|
25
|
+
}) => {
|
|
26
|
+
const resourceData = authData.value?.resources.find(
|
|
27
|
+
(r) => r.nombre === resource
|
|
28
|
+
);
|
|
29
|
+
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;
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
user,
|
|
39
|
+
authData,
|
|
40
|
+
isAuthenticated,
|
|
41
|
+
token,
|
|
42
|
+
logout,
|
|
43
|
+
update,
|
|
44
|
+
hasResource,
|
|
45
|
+
hasAuthorizationInResource
|
|
46
|
+
};
|
|
69
47
|
});
|
|
@@ -40,10 +40,6 @@ export interface IUnaNuxtModuleOptions {
|
|
|
40
40
|
* Lista de permisos o alcances solicitados.
|
|
41
41
|
*/
|
|
42
42
|
scope: String[];
|
|
43
|
-
/**
|
|
44
|
-
* Indica si se debe validar el IDToken.
|
|
45
|
-
*/
|
|
46
|
-
validateIDToken: string;
|
|
47
43
|
};
|
|
48
44
|
/**
|
|
49
45
|
* Configuración de las APIs utilizadas por el módulo.
|
|
@@ -357,23 +353,6 @@ export interface IAppStatusState {
|
|
|
357
353
|
/** Almacena si se debe abrir el diálogo de exportar */
|
|
358
354
|
openDialogExport: boolean;
|
|
359
355
|
}
|
|
360
|
-
/**
|
|
361
|
-
* Interfaz para el Store de preferencias visuales del usuario.
|
|
362
|
-
*
|
|
363
|
-
* @interface IUiCustomizerState
|
|
364
|
-
*
|
|
365
|
-
* @property {boolean} - *drawSidebar* - Almacena si se debe renderizar el menú
|
|
366
|
-
* @property {boolean} - *isSidebarMini* - Almacena si el menú esta minimizado
|
|
367
|
-
* @property {string} - *currentTheme* - Almacena el tema actual
|
|
368
|
-
*/
|
|
369
|
-
export interface IUiCustomizerState {
|
|
370
|
-
/** Almacena si se debe renderizar el menú */
|
|
371
|
-
drawSidebar: boolean;
|
|
372
|
-
/** Almacena si el menú esta minimizado */
|
|
373
|
-
isSidebarMini: boolean;
|
|
374
|
-
/** Almacena el tema actual */
|
|
375
|
-
currentTheme: string;
|
|
376
|
-
}
|
|
377
356
|
/**
|
|
378
357
|
* Interfaz para la información del usuario autenticado.
|
|
379
358
|
*
|
|
@@ -441,20 +420,6 @@ export interface IAuthData {
|
|
|
441
420
|
/** Recursos del usuario */
|
|
442
421
|
resources: IResource[];
|
|
443
422
|
}
|
|
444
|
-
/**
|
|
445
|
-
* Interfaz para el Store de autenticación y autorización.
|
|
446
|
-
*
|
|
447
|
-
* @interface IAuthState
|
|
448
|
-
*
|
|
449
|
-
* @property {IAuthenticatedUser, null} - *user* - Información del usuario
|
|
450
|
-
* @property {IAuthData, null} - *authData* - Información de la sesión del usuario
|
|
451
|
-
*/
|
|
452
|
-
export interface IAuthState {
|
|
453
|
-
/** Información del usuario */
|
|
454
|
-
user: IAuthenticatedUser | null;
|
|
455
|
-
/** Información de la sesión del usuario */
|
|
456
|
-
authData: IAuthData | null;
|
|
457
|
-
}
|
|
458
423
|
/**
|
|
459
424
|
* Interfaz para los parámetros de métodos de validacion de permisos en recursos.
|
|
460
425
|
*
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "una-nuxt-module",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Módulo Nuxt para desarrollo CGI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "
|
|
7
|
+
"url": ""
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"type": "module",
|
|
@@ -32,31 +32,31 @@
|
|
|
32
32
|
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@asgardeo/auth-spa": "^3.
|
|
36
|
-
"@nuxt/image": "^1.
|
|
37
|
-
"@nuxt/kit": "^3.
|
|
38
|
-
"@nuxtjs/i18n": "9.
|
|
35
|
+
"@asgardeo/auth-spa": "^3.2.0",
|
|
36
|
+
"@nuxt/image": "^1.10.0",
|
|
37
|
+
"@nuxt/kit": "^3.16.1",
|
|
38
|
+
"@nuxtjs/i18n": "9.5.3",
|
|
39
39
|
"defu": "^6.1.4",
|
|
40
|
-
"pinia": "^
|
|
40
|
+
"pinia": "^3.0.1",
|
|
41
41
|
"vue-json-pretty": "^2.4.0",
|
|
42
|
-
"vuetify": "^3.7.
|
|
42
|
+
"vuetify": "^3.7.19"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@nuxt/devtools": "^
|
|
46
|
-
"@nuxt/eslint-config": "^
|
|
45
|
+
"@nuxt/devtools": "^2.3.2",
|
|
46
|
+
"@nuxt/eslint-config": "^1.2.0",
|
|
47
47
|
"@nuxt/module-builder": "^0.8.4",
|
|
48
|
-
"@nuxt/schema": "^3.
|
|
49
|
-
"@nuxt/test-utils": "^3.
|
|
50
|
-
"@pinia/nuxt": "^0.
|
|
48
|
+
"@nuxt/schema": "^3.16.1",
|
|
49
|
+
"@nuxt/test-utils": "^3.17.2",
|
|
50
|
+
"@pinia/nuxt": "^0.10.1",
|
|
51
51
|
"@types/node": "latest",
|
|
52
|
-
"changelogen": "^0.
|
|
53
|
-
"eslint": "^9.
|
|
54
|
-
"nuxt": "^3.
|
|
55
|
-
"sass": "^1.
|
|
56
|
-
"sass-loader": "^16.0.
|
|
52
|
+
"changelogen": "^0.6.1",
|
|
53
|
+
"eslint": "^9.23.0",
|
|
54
|
+
"nuxt": "^3.16.1",
|
|
55
|
+
"sass": "^1.86.0",
|
|
56
|
+
"sass-loader": "^16.0.5",
|
|
57
57
|
"typescript": "latest",
|
|
58
|
-
"vitest": "^
|
|
59
|
-
"vue-tsc": "^2.
|
|
58
|
+
"vitest": "^3.0.9",
|
|
59
|
+
"vue-tsc": "^2.2.8"
|
|
60
60
|
},
|
|
61
61
|
"directories": {
|
|
62
62
|
"test": "test"
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convierte una cadena de texto a un valor booleano.
|
|
3
|
-
*
|
|
4
|
-
* - Retorna `true` si el texto es `"true"` (sin distinción de mayúsculas o minúsculas).
|
|
5
|
-
* - Cualquier otro valor (incluidos nulos o indefinidos) será convertido a `false`.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} value - Texto a convertir.
|
|
8
|
-
* @returns {boolean}
|
|
9
|
-
*/
|
|
10
|
-
declare const _default: (value: string) => boolean;
|
|
11
|
-
export default _default;
|