Skip to content

Commit

Permalink
4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Fi1osof committed Jun 3, 2020
1 parent 6922d26 commit 32c80c9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
4.1.0
============================================
- Added permissions middleware

4.0.6
============================================
- Added CallRequestButtons
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prisma-cms/boilerplate",
"version": "4.0.6",
"version": "4.1.0",
"description": "Opensource framework CMS powered by GraphQL, Prisma, MySQL, React & Apollo GraphQL",
"private": false,
"scripts": {
Expand Down Expand Up @@ -50,6 +50,7 @@
"cheerio": "^1.0.0-rc.2",
"graphql": "14.0.2",
"graphql-tag": "2.10.0",
"graphql-shield": "^7.3.0",
"material-ui": "1.0.0-beta.43",
"material-ui-icons": "^1.0.0-beta.17",
"merge-graphql-schemas": "latest",
Expand Down
2 changes: 2 additions & 0 deletions src/server/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getProjectFromRequest,
} from "@prisma-cms/marketplace-module";
import CoreModule from "./modules";
// import permissions from './middleware/permissions';

import Web3 from "web3";

Expand Down Expand Up @@ -73,6 +74,7 @@ const web3 = new Web3(GethServer);


const middlewares = [
// permissions,
paginationMiddleware,
];

Expand Down
42 changes: 42 additions & 0 deletions src/server/middleware/permissions/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

import GraphQLShield from 'graphql-shield';

const {
rule,
// and,
// or,
shield,
} = GraphQLShield;

const rules = {
isSudo: rule({ cache: 'no_cache' })((source, args, ctx) => {

const {
currentUser,
} = ctx;

const {
sudo,
} = currentUser || {};

return sudo === true;
}),
};

export default shield(
{
// Query: {
// users: rules.isSudo,
// },
// Mutation: {
// updateUserProcessor: rules.isSudo,
// },
},
{
fallbackError: (error, parent, args, context, info) => {

return error || new Error("Доступ запрещен");
},
}
);

0 comments on commit 32c80c9

Please sign in to comment.