System Information
- Strapi Version: 4
- Operating System: Mac
- Database: Posgres
- Node Version:
- NPM Version:
- Yarn Version:
After digging it for few hours I figured out that the code for allowing default permission for public role will somewhat look like this:
async bootstrap({ strapi }) {
const findPublicRole = async () => {
const publicRole = await strapi
.query("plugin::users-permissions.role")
.findOne({
where: {
type: "public",
},
});
console.log(publicRole);
return publicRole;
};
const setDefaultPermissions = async () => {
const role = await findPublicRole();
const permissions = await strapi
.query("plugin::users-permissions.permission")
.findMany({ type: "public", role: role.id });
console.log(permissions);
await Promise.all(
permissions.map((p) =>
strapi.query("plugin::users-permissions.permission").update({
where: { id: p.id },
data: {
enabled: true,
},
})
)
);
};
await setDefaultPermissions();
},
But the problem here is the code isn’t setting all the permissions. I want to set all permissions by default while bootstrapping.
In the image below I want to allow all (inshort tick all the checkboxes)
what am I doing wrong with my code? Please help.