Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mapomodule/core

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapomodule/core - npm Package Compare versions

Comparing version 1.0.0-alpha.40 to 1.0.0-alpha.41

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [1.0.0-alpha.41](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.40...v1.0.0-alpha.41) (2022-12-20)
### Features
* handle all_permissions prop in user ([14d4252](https://github.com/lotrekagency/mapo/commit/14d425215434e29f82093fc96e53b172bf247b8f))
# [1.0.0-alpha.40](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.39...v1.0.0-alpha.40) (2022-12-20)

@@ -8,0 +19,0 @@

53

middleware/permissions.js

@@ -1,19 +0,36 @@

import Middleware from '../../middleware' // little hack to inject middleware in root project :P
import Middleware from "../../middleware"; // little hack to inject middleware in root project :P
Middleware.permissions = Middleware.permissions || async function ({ route, error, store }) {
route.meta = Array.isArray(route.meta) ? route.meta[0] : route.meta
if (!route.meta.permissions) return
const userInfo = store.getters['mapo/user/info']
if (userInfo.is_superuser) {
await store.dispatch('mapo/user/addPagePermission', {key: route.name, value: ["add", "change", "delete", "view"]})
return
}
const { model } = route.meta.permissions
const userPermission = (userInfo.user_permissions || []).filter(perm => perm.codename.endsWith(model)).map(({ codename }) => codename.replace(`_${model}`, ''))
if (!userPermission.includes('view')) {
return error({ statusCode: 404, message: 'This page could not be found' })
} else {
await store.dispatch('mapo/user/addPagePermission', {key: route.name, value: userPermission})
return
}
}
Middleware.permissions =
Middleware.permissions ||
async function ({ route, error, store }) {
route.meta = Array.isArray(route.meta) ? route.meta[0] : route.meta;
if (!route.meta.permissions) return;
const userInfo = store.getters["mapo/user/info"];
if (userInfo.is_superuser) {
await store.dispatch("mapo/user/addPagePermission", {
key: route.name,
value: ["add", "change", "delete", "view"],
});
return;
}
const { model } = route.meta.permissions;
const userPermission = (
userInfo.all_permissions ||
userInfo.user_permissions ||
[]
)
.filter((perm) => perm.codename.endsWith(model))
.map(({ codename }) => codename.replace(`_${model}`, ""));
if (!userPermission.includes("view")) {
return error({
statusCode: 404,
message: "This page could not be found",
});
} else {
await store.dispatch("mapo/user/addPagePermission", {
key: route.name,
value: userPermission,
});
return;
}
};
{
"name": "@mapomodule/core",
"version": "1.0.0-alpha.40",
"version": "1.0.0-alpha.41",
"description": "This is part of Mapo nuxt module. Injects the core mapo plugin helpers.",

@@ -21,3 +21,3 @@ "author": "bnznamco <gabriele.baldi.01@gmail.com>",

},
"gitHead": "918d8d3ed9a6edc9be25e082f9917866e8c73c57"
"gitHead": "9f6bc45ab0ae3b56ed6fa98597c80808efced174"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc