Editor role cannot edit Single Types

System Information
  • Strapi Version: 3.4.5
  • Operating System: Ubuntu 18
  • Database: Mysql
  • Node Version: 14.15.4
  • NPM Version: 6.14.10
  • Yarn Version: 1.22.5

I create a new strapi project. I’m running it with “yarn develop”.
I have configured NGINX to work with my subdomain.
I created 3 SINGLE TYPES content with Super User.
Then I created another user in “ADMINISTRATION PANEL → Users” and gave that user the role editor.

But this user cannot edit anything besides the Plugin Media Library.

What do I need to do for the user-created as Editor to be able to edit any content?


This doesn’t work in development mode and also single mode. Basically, the Editor role has absolutely zero permission by default and there is no way to give him permission as all those fields show as not available.
Every where I read it says the Editor has the capability to edit content of other author. I gave him the author role and same thing cannot create any content.

@sam-pires / @maeva tagging you for clarification

1 Like

Thanks so much for your quick support @DMehaffy

The solution to my problem was as simple as clicking on the content items and then the RBAC Editor role was automatically able to edit what was selected.

1 Like

Yeah taking a second look with you I can understand the confusion, the UI here isn’t really clear as everything looks very grayed out and it’s hard to determine where to click to enable things.

1 Like

Is it possible the limit the number of items an editor for example may create?
so in collection “dishes” he may add 30 items, and on collection “cooks”, just one?
thanks.

Not currently @aviavia, it might be possible with the conditionals that are in beta (no public documentation for them yet) but those options are only in our Enterprise editions

Thanks, so is there an api, or something I may use?

@aviavia are you an EE user? (Do you have an EE license or are you just using the CE?)

I am on a free plan for now. Does the Bronze plan is included as Enterpize?

Yes it does, the only EE feature that is not in all 3 plans right now is SSO (Gold only)

So i will be able to achive that functionality? The wholle idea depends on it.

It should be yes using conditionals, the documentation for that isn’t released yet but I can provide the prototype here (this may be subject to change when we release I18N):

Using RBAC conditions

:warning: Warning

This API is considerred unstable for now

Adding a new condition


In your bootstrap file located in ./config/functions/bootstrap.js you can do the following:

const conditions = [
  {
    displayName: "Entity has same name as user",
    name: "same-name-as-user",
    plugin: "name of a plugin if created in a plugin"
    handler: (user) => {
      return { name: user.name };
    },
  },
];
​
module.exports = () => {
  // do your boostrap
​
  strapi.admin.services.permission.conditionProvider.registerMany(conditions);
};

Condition


A condition have 4 possible properties:

  • displayName: name showed in the UI
  • name: technical name. Should be kebab-cased
  • plugin: If you create a plugin condition add the plugin name. e.g content-manager
  • handler: A function (sync or async) that returns a condition object. Read more here

Handler


The condition handler receives the authenticated user making the request.

It should return oneOf:

  • true:

    Returning true means the condition will always match.
    It is usefull if you want to verify an external condition or a condition on the authenticated user only.
    const condition = {
      displayName: "Can drink",
      name: "can-drink",
      async handler(user) {
        if (user.age > 21) return true;
        return false;
      },
    };
    

  • false:

    Returning false means the condition will never match.
    It is usefull if you want to verify an external condition or a condition on the authenticated user only.
    const condition = {
      displayName: "Can drink",
      name: "can-drink",
      async handler(user) {
        if (user.age < 21) return false;
        return true;
      },
    };
    

  • Condition object:

    A condition obect is an matcher object that will allow verify conditions on the entities you read, create, update or delete.

    We use sift.js behind the scenes to do the condition matching. Here are the list of allowed operators:
    • $or
    • $eq
    • $ne
    • $in
    • $nin
    • $lt
    • $lte
    • $gt
    • $gte
    • $exists
    • $elemMatch

      Examples
    const condition = {
      displayName: "price greater than 50",
      name: "pricate-gt-50",
      async handler(user) {
        return { price: { $gt: 50 } };
      },
    };
    

So I will be able to create a condition that counts how many items current user created on that collection , and checks the user’s role, and according to the returned true or false, will display/ or not the “add more items” button?
And when will this feature be available?
Thanks

I believe so, though I’ve never need a conditional like that. The feature already exists, it’s just in a beta/prototype stage. We expect some changes when I18N is released but outside of that I don’t have a “stable” date for it yet.

Thanks,
could anyone return to me with an official reply and a code sample?
As I need to decide whether to pay for the yearly plan to achieve this feature or create a client that can handle this, which is redundant work and an asset to host, deploy, manage, etc".
You didn’t need it, but the use case is so basic, and probably very required for many others. I think it should be implemented in the “roles” settings, with the checkboxes, where you would simply have an input allowing you to limit the number of items a role can add.
Thanks.

@aviavia we have a PR open right now to add documentation about conditionals right now:

1 Like