fix: 收紧客服功能访问权限
This commit is contained in:
@@ -18,19 +18,19 @@ import ResponsesPendingIndex from './responses/Pending.vue';
|
||||
import CustomToolsIndex from './tools/Index.vue';
|
||||
|
||||
const meta = {
|
||||
permissions: ['administrator', 'agent'],
|
||||
permissions: ['administrator'],
|
||||
featureFlag: FEATURE_FLAGS.CAPTAIN,
|
||||
installationTypes: [INSTALLATION_TYPES.CLOUD, INSTALLATION_TYPES.ENTERPRISE],
|
||||
};
|
||||
|
||||
const metaCustomTools = {
|
||||
permissions: ['administrator', 'agent'],
|
||||
permissions: ['administrator'],
|
||||
featureFlag: FEATURE_FLAGS.CAPTAIN_CUSTOM_TOOLS,
|
||||
installationTypes: [INSTALLATION_TYPES.CLOUD, INSTALLATION_TYPES.ENTERPRISE],
|
||||
};
|
||||
|
||||
const metaV2 = {
|
||||
permissions: ['administrator', 'agent'],
|
||||
permissions: ['administrator'],
|
||||
featureFlag: FEATURE_FLAGS.CAPTAIN_V2,
|
||||
installationTypes: [INSTALLATION_TYPES.CLOUD, INSTALLATION_TYPES.ENTERPRISE],
|
||||
};
|
||||
@@ -106,7 +106,7 @@ const assistantRoutes = [
|
||||
component: AssistantEmptyStateIndex,
|
||||
name: 'captain_assistants_create_index',
|
||||
meta: {
|
||||
permissions: ['administrator', 'agent'],
|
||||
permissions: ['administrator'],
|
||||
installationTypes: [
|
||||
INSTALLATION_TYPES.CLOUD,
|
||||
INSTALLATION_TYPES.ENTERPRISE,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const source = readFileSync(
|
||||
'app/javascript/dashboard/routes/dashboard/captain/captain.routes.js',
|
||||
'utf8'
|
||||
);
|
||||
|
||||
describe('Captain routes', () => {
|
||||
it('restricts the whole Captain module to administrators', () => {
|
||||
expect(source).not.toContain("permissions: ['administrator', 'agent']");
|
||||
expect(source.match(/permissions: \['administrator'\]/g)?.length).toBe(4);
|
||||
});
|
||||
});
|
||||
+11
-10
@@ -26,6 +26,10 @@ const meta = {
|
||||
featureFlag: FEATURE_FLAGS.HELP_CENTER,
|
||||
permissions: ['administrator', 'agent', 'knowledge_base_manage'],
|
||||
};
|
||||
const adminMeta = {
|
||||
featureFlag: FEATURE_FLAGS.HELP_CENTER,
|
||||
permissions: ['administrator', 'knowledge_base_manage'],
|
||||
};
|
||||
const portalRoutes = [
|
||||
{
|
||||
path: getPortalRoute(':portalSlug/:locale/:categorySlug?/articles/:tab?'),
|
||||
@@ -51,7 +55,7 @@ const portalRoutes = [
|
||||
{
|
||||
path: getPortalRoute(':portalSlug/:locale/categories'),
|
||||
name: 'portals_categories_index',
|
||||
meta,
|
||||
meta: adminMeta,
|
||||
component: PortalsCategoriesIndexPage,
|
||||
},
|
||||
{
|
||||
@@ -59,7 +63,7 @@ const portalRoutes = [
|
||||
':portalSlug/:locale/categories/:categorySlug/articles'
|
||||
),
|
||||
name: 'portals_categories_articles_index',
|
||||
meta,
|
||||
meta: adminMeta,
|
||||
component: PortalsArticlesIndexPage,
|
||||
},
|
||||
{
|
||||
@@ -67,7 +71,7 @@ const portalRoutes = [
|
||||
':portalSlug/:locale/categories/:categorySlug/articles/new'
|
||||
),
|
||||
name: 'portals_categories_articles_new',
|
||||
meta,
|
||||
meta: adminMeta,
|
||||
component: PortalsArticlesNewPage,
|
||||
},
|
||||
{
|
||||
@@ -75,28 +79,25 @@ const portalRoutes = [
|
||||
':portalSlug/:locale/categories/:categorySlug/articles/:articleSlug'
|
||||
),
|
||||
name: 'portals_categories_articles_edit',
|
||||
meta,
|
||||
meta: adminMeta,
|
||||
component: PortalsArticlesEditPage,
|
||||
},
|
||||
{
|
||||
path: getPortalRoute(':portalSlug/locales'),
|
||||
name: 'portals_locales_index',
|
||||
meta,
|
||||
meta: adminMeta,
|
||||
component: PortalsLocalesIndexPage,
|
||||
},
|
||||
{
|
||||
path: getPortalRoute(':portalSlug/settings'),
|
||||
name: 'portals_settings_index',
|
||||
meta,
|
||||
meta: adminMeta,
|
||||
component: PortalsSettingsIndexPage,
|
||||
},
|
||||
{
|
||||
path: getPortalRoute('new'),
|
||||
name: 'portals_new',
|
||||
meta: {
|
||||
featureFlag: FEATURE_FLAGS.HELP_CENTER,
|
||||
permissions: ['administrator', 'knowledge_base_manage'],
|
||||
},
|
||||
meta: adminMeta,
|
||||
component: PortalsNew,
|
||||
},
|
||||
{
|
||||
|
||||
+23
-3
@@ -1,4 +1,5 @@
|
||||
import helpcenterRoutes from './helpcenter.routes';
|
||||
import { routeIsAccessibleFor } from 'dashboard/helper/routeHelpers';
|
||||
|
||||
const findRoute = name => {
|
||||
const [rootRoute] = helpcenterRoutes.routes;
|
||||
@@ -11,9 +12,28 @@ describe('Help center routes', () => {
|
||||
});
|
||||
|
||||
it('keeps article routes accessible to agents', () => {
|
||||
expect(findRoute('portals_articles_index').meta.permissions).toContain(
|
||||
'agent'
|
||||
);
|
||||
[
|
||||
'portals_articles_index',
|
||||
'portals_articles_new',
|
||||
'portals_articles_edit',
|
||||
].forEach(routeName => {
|
||||
expect(findRoute(routeName).meta.permissions).toContain('agent');
|
||||
});
|
||||
});
|
||||
|
||||
it('restricts category, locale, and portal settings routes from agents', () => {
|
||||
[
|
||||
'portals_categories_index',
|
||||
'portals_categories_articles_index',
|
||||
'portals_categories_articles_new',
|
||||
'portals_categories_articles_edit',
|
||||
'portals_locales_index',
|
||||
'portals_settings_index',
|
||||
].forEach(routeName => {
|
||||
const route = findRoute(routeName);
|
||||
expect(routeIsAccessibleFor(route, ['agent'])).toBe(false);
|
||||
expect(routeIsAccessibleFor(route, ['administrator'])).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps portal creation restricted to administrators or custom roles', () => {
|
||||
|
||||
Reference in New Issue
Block a user