@mapomodule/core 1.0.0-alpha.15 → 1.0.0-alpha.18

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,45 @@
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.18](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.17...v1.0.0-alpha.18) (2022-04-04)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * fix core interceptor syntax ([c546a48](https://github.com/lotrekagency/mapo/commit/c546a48f22bf689d4b679aaab82b2b9ed62f26cc))
12
+
13
+
14
+
15
+
16
+
17
+ # [1.0.0-alpha.17](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.16...v1.0.0-alpha.17) (2022-04-03)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * various fixes to auth loops ([58cdb58](https://github.com/lotrekagency/mapo/commit/58cdb586e88df8e595876ba4dd4d4cc11865f7e3))
23
+
24
+
25
+
26
+
27
+
28
+ # [1.0.0-alpha.16](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.15...v1.0.0-alpha.16) (2022-04-03)
29
+
30
+
31
+ ### Features
32
+
33
+ * Added mapo integrations module! 🎉 ([76d2c80](https://github.com/lotrekagency/mapo/commit/76d2c805245b4cf49a33696339da52e4c17f4053))
34
+ * added mapo options to mapo helper ([38dcbf2](https://github.com/lotrekagency/mapo/commit/38dcbf28d286eb02c2a6785a883a14edaa0837b1))
35
+
36
+
37
+ ### BREAKING CHANGES
38
+
39
+ * This change removes all the camomilla cms references moving the compatibility layer in a detached package [mapo-integrations-camomilla](https://github.com/lotrekagency/mapo-integrations-camomilla). The guidelines to make mapo work with camomilla will be provided in the package readme.
40
+
41
+
42
+
43
+
44
+
6
45
  # [1.0.0-alpha.15](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2022-03-11)
7
46
 
8
47
 
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import createRepository from '@mapomodule/core/api/crud'
2
2
  import transformRequestInMultipart from '@mapomodule/core/api/multipart'
3
3
  import initInterceptors from '@mapomodule/core/interceptor'
4
+ import options from './options'
4
5
 
5
6
  function getRouteMiddlewares(route) {
6
7
  const meta = Array.isArray(route?.meta) ? route.meta[0] : route.meta
@@ -8,6 +9,7 @@ function getRouteMiddlewares(route) {
8
9
  return (typeof middleware === "string" ? [middleware] : middleware) || []
9
10
  }
10
11
 
12
+ const { axios, ...conf } = options;
11
13
 
12
14
  export default (ctx, inject) => {
13
15
 
@@ -19,8 +21,10 @@ export default (ctx, inject) => {
19
21
  */
20
22
  $api: {
21
23
  crud: createRepository(ctx.$axios),
22
- multipart: transformRequestInMultipart
24
+ multipart: transformRequestInMultipart,
25
+ conf: axios
23
26
  },
27
+ $options: conf,
24
28
  /**
25
29
  * From here you can reach some utilities that simplify the interaction with the user authentication flow.
26
30
  */
@@ -35,7 +39,7 @@ export default (ctx, inject) => {
35
39
  *
36
40
  * This simply commits a logout to the vuex store.
37
41
  */
38
- logout: () => ctx.store.dispatch("mapo/user/login"),
42
+ logout: () => ctx.store.dispatch("mapo/user/logout"),
39
43
  /**
40
44
  * This refresh user informations present in vuex store and returns them.
41
45
  * @returns {UserData}
@@ -19,9 +19,9 @@ 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
+ if (status === 401 && (request || {}).path !== '/api/auth/logout') {
24
+ store.dispatch('mapo/user/logout')
25
25
  }
26
26
  if (status == 403) {
27
27
  store.dispatch("mapo/app/showSnackMessage", { message: "Permission denied..", color: "error" })
@@ -1,8 +1,8 @@
1
1
  import Middleware from '../../middleware' // little hack to inject middleware in root project :P
2
2
 
3
3
  Middleware.auth = Middleware.auth || function ({ route, redirect, query, store }) {
4
- const hasToken = store.getters['mapo/user/token']
5
- if (!hasToken) {
4
+ const isLoggedIn = store.getters['mapo/user/isLoggedIn']
5
+ if (!isLoggedIn) {
6
6
  query['redirect'] = route.path
7
7
  return redirect('/login', query)
8
8
  }
@@ -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/module.js CHANGED
@@ -23,6 +23,13 @@ export default async function (moduleOptions) {
23
23
  fileName: path.join(namespace, 'mapo.js')
24
24
  })
25
25
 
26
+ // INJECT MAPO OPTIONS
27
+ this.addTemplate({
28
+ src: path.resolve(__dirname, './options.js'),
29
+ fileName: path.join(namespace, 'options.js'),
30
+ options: { axios: (this.options && this.options.axios), ...moduleOptions }
31
+ })
32
+
26
33
  // INJECT ALL MIDDLEWARES
27
34
  const middlewares = (await resolver.resolveRelative(__dirname, 'middleware')).map(({ src }) => src)
28
35
 
package/options.js ADDED
@@ -0,0 +1 @@
1
+ export default <%= serializeFunction(options) %>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/core",
3
- "version": "1.0.0-alpha.15",
3
+ "version": "1.0.0-alpha.18",
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": "cd42b3dd094ef3bf743c67819e6059bf9ccac491"
21
+ "gitHead": "1b05e625339b6ee6ed0e238739cc31fbd84f3397"
22
22
  }