strapi-community / strapi-plugin-protected-populate

MIT License
20 stars 5 forks source link

Change way to handle user configuration #6

Closed remidej closed 1 year ago

remidej commented 1 year ago

Hello,

It looks like the way to configure your plugin is to create a dedicated /protected-populate/index.json file in an application. This works, but I think there are other solutions you could use that are more the "Strapi way".

One would be to use the app-wide config/plugins.js file to handle it, where inside your plugin's key you should be able to enter the same contents as the JSON file you're currently using.

The other is to define the config for each content type in its schema file. The pluginOptions object exists for this purpose, and it's what is used by the i18n plugin to decide which content types should be translated.

Boegie19 commented 1 year ago

Thanks for the feedback.

Using a content type would be a issue since I want the plugin data not to be stuck in the database. Since if you switch databases from testing to prod it should still keep protecting your routes. also I protect the route not the content type.

So if I where to do that It would make more sense to add that information to the route but then I get in trouble with other plugins since I would have to edit there route configs what would lead to lots more complexity.

My idea at first was to add it to config/plugins.js but then my problem would become that every time I have to do anything configuration for any plugin I would have to go to a 1000+ line file of protected routes in any normal strapi instance using this. what I would find not acceptable.

Also plugins.js is a js file so adding my custom config to it is harder then with a json file

So that is why I split the file off.

prestonator commented 1 year ago

@remidej Hey! Do you mind sharing how you got this plugin to work? I'm stuck at rebuilding the admin panel, and don't particularly know where to start with creating the files you mentioned. Any help would be very much appreciated :)

Boegie19 commented 1 year ago

remidej Hey! Do you mind sharing how you got this plugin to work? I'm stuck at rebuilding the admin panel, and don't particularly know where to start with creating the files you mentioned. Any help would be very much appreciated :)

After you rebuild the admin it should create a new tab in the main menu where you can configure everyting if this is not the cease I would like some more information