mirror of
https://github.com/strapi/strapi.git
synced 2025-07-31 21:09:39 +00:00
37 lines
763 B
JavaScript
37 lines
763 B
JavaScript
'use strict';
|
|
|
|
const conditions = [
|
|
{
|
|
displayName: 'Has Locale Access',
|
|
name: 'has-locale-access',
|
|
plugin: 'i18n',
|
|
handler(user, options) {
|
|
const { locales } = options.permission.properties || {};
|
|
const { superAdminCode } = strapi.admin.services.role.constants;
|
|
|
|
const isSuperAdmin = user.roles.some((role) => role.code === superAdminCode);
|
|
|
|
if (isSuperAdmin) {
|
|
return true;
|
|
}
|
|
|
|
return {
|
|
locale: {
|
|
$in: locales || [],
|
|
},
|
|
};
|
|
},
|
|
},
|
|
];
|
|
|
|
const registerI18nConditions = async () => {
|
|
const { conditionProvider } = strapi.admin.services.permission;
|
|
|
|
await conditionProvider.registerMany(conditions);
|
|
};
|
|
|
|
module.exports = {
|
|
conditions,
|
|
registerI18nConditions,
|
|
};
|