@mapomodule/core 1.0.0-alpha.16 → 1.0.0-alpha.19

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/CHANGELOG.md CHANGED
@@ -3,6 +3,39 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.19](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.18...v1.0.0-alpha.19) (2022-04-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix logout loop ([3177cca](https://github.com/lotrekagency/mapo/commit/3177ccaf4be6151feec379c4241f8784b79d4361))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.0.0-alpha.18](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.17...v1.0.0-alpha.18) (2022-04-04)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * fix core interceptor syntax ([c546a48](https://github.com/lotrekagency/mapo/commit/c546a48f22bf689d4b679aaab82b2b9ed62f26cc))
23
+
24
+
25
+
26
+
27
+
28
+ # [1.0.0-alpha.17](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.16...v1.0.0-alpha.17) (2022-04-03)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * various fixes to auth loops ([58cdb58](https://github.com/lotrekagency/mapo/commit/58cdb586e88df8e595876ba4dd4d4cc11865f7e3))
34
+
35
+
36
+
37
+
38
+
6
39
  # [1.0.0-alpha.16](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.15...v1.0.0-alpha.16) (2022-04-03)
7
40
 
8
41
 
@@ -1,5 +1,5 @@
1
1
  module.exports = ({ $axios, store }) => {
2
- if ($axios && store){
2
+ if ($axios && store) {
3
3
  $axios.onRequest((config) => {
4
4
  const token = store.getters['mapo/user/token']
5
5
  if (token && token !== 'undefined') {
@@ -7,7 +7,7 @@ module.exports = ({ $axios, store }) => {
7
7
  }
8
8
  return config
9
9
  })
10
-
10
+
11
11
  $axios.onResponse((response) => {
12
12
  if (response.status === 401) {
13
13
  store.dispatch('mapo/user/logout');
@@ -19,9 +19,11 @@ module.exports = ({ $axios, store }) => {
19
19
  })
20
20
 
21
21
  $axios.onError((error) => {
22
- const { status } = error.response || {}
23
- if (status === 401) {
24
- store.dispatch('mapo/user/logout');
22
+ const { status, request } = error.response || {}
23
+ const baseURL = ($axios.defaults.baseURL || "").replace(/https?:\/\/[^\/]+/i, "")
24
+ const logoutPath = `${baseURL.endsWith("/") ? baseURL : baseURL + "/"}${process.env.AUTH_LOGIN_URL || "api/auth/logout"}`
25
+ if (status === 401 && (request || {}).path !== logoutPath) {
26
+ store.dispatch('mapo/user/logout')
25
27
  }
26
28
  if (status == 403) {
27
29
  store.dispatch("mapo/app/showSnackMessage", { message: "Permission denied..", color: "error" })
@@ -9,7 +9,7 @@ Middleware.permissions = Middleware.permissions || async function ({ route, erro
9
9
  return
10
10
  }
11
11
  const { model } = route.meta.permissions
12
- const userPermission = userInfo.user_permissions.filter(perm => perm.codename.endsWith(model)).map(({ codename }) => codename.replace(`_${model}`, ''))
12
+ const userPermission = (userInfo.user_permissions || []).filter(perm => perm.codename.endsWith(model)).map(({ codename }) => codename.replace(`_${model}`, ''))
13
13
  if (!userPermission.includes('view')) {
14
14
  return error({ statusCode: 404, message: 'This page could not be found' })
15
15
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/core",
3
- "version": "1.0.0-alpha.16",
3
+ "version": "1.0.0-alpha.19",
4
4
  "description": "This is part of Mapo nuxt module. Injects the core mapo plugin helpers.",
5
5
  "author": "bnznamco <gabriele.baldi.01@gmail.com>",
6
6
  "keywords": [
@@ -18,5 +18,5 @@
18
18
  "publishConfig": {
19
19
  "access": "public"
20
20
  },
21
- "gitHead": "2ef4275464cd8eb28cbbc61c980355b1379186b5"
21
+ "gitHead": "3bc598b7ecb64c67a164b438847eb237f78efc75"
22
22
  }