Skip to content

Instantly share code, notes, and snippets.

View 8byr0's full-sized avatar

Hugues BUREAU 8byr0

View GitHub Profile
@8byr0
8byr0 / isOwner.js
Last active June 26, 2020 16:00
Is Owner policy for strapi HTTP (Not working with graphql). Freely inspired from https://github.com/strapi/strapi/issues/624#issuecomment-558666801
'use strict';
/**
* `isowner` policy.
*/
const pluralize = require('pluralize');
module.exports = async (ctx, next) => {
try {
const errMsg = 'You are not allowed to perform this action.';
@8byr0
8byr0 / isCreatedBy.js
Created November 11, 2019 08:02
Strapi policy: add and use `createdBy` field to models
'use strict';
/**
* `isCreatedBy` policy.
* group `administrator` must be created from interface
*/
module.exports = async (ctx, next, args) => {
const { id } = ctx.state.user;
const role = ctx.state.user.role.type
if (role !== "administrator") {