una-nuxt-module 3.0.7 → 3.0.9
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
package/dist/module.mjs
CHANGED
|
@@ -5,19 +5,19 @@ export default defineNuxtRouteMiddleware(async () => {
|
|
|
5
5
|
if (!import.meta.client) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
+
const { $pinia, $signIn, $authData, $isAuthenticated, $accessToken } = useNuxtApp();
|
|
8
9
|
const authorization = useAuthorization();
|
|
9
|
-
const authStore = useAuthStore();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (!authConfig.sso?.automaticSignIn) {
|
|
17
|
-
await $signIn();
|
|
18
|
-
}
|
|
19
|
-
return;
|
|
10
|
+
const authStore = useAuthStore($pinia);
|
|
11
|
+
const isAuthenticated = await $isAuthenticated();
|
|
12
|
+
if (!isAuthenticated) {
|
|
13
|
+
const runtimeConfig = useRuntimeConfig();
|
|
14
|
+
const authConfig = runtimeConfig.public.unaxt.auth;
|
|
15
|
+
if (!authConfig.sso?.automaticSignIn) {
|
|
16
|
+
await $signIn();
|
|
20
17
|
}
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (!authStore.isAuthenticated) {
|
|
21
21
|
const authResponse = await $authData();
|
|
22
22
|
const token = await $accessToken();
|
|
23
23
|
const resources = await authorization.getResources(token);
|