Grant the static super-admin mobile full ALL_RIDS and move slider into ثابتها permissions.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
* gated by `users.isSuperAdmin` in place instead.
|
||||
*
|
||||
* Keep in step with SUPER_ADMIN_RIDS in apps/api/src/modules/auth/super-admin.ts.
|
||||
* Login/JWT for that mobile grants the full ALL_RIDS set on the API side; this
|
||||
* set is only the tree-filter used when editing other roles' permissions.
|
||||
*/
|
||||
export const SUPER_ADMIN_RIDS: ReadonlySet<string> = new Set([
|
||||
'persons.create.single',
|
||||
|
||||
@@ -94,10 +94,10 @@
|
||||
<a-button class="mt-4" type="primary" @click="saveTags">ذخیره برچسب ها</a-button>
|
||||
</a-tab-pane>
|
||||
|
||||
<!-- اسلایدر موبایل — دسترسی جدا از بقیهی این صفحه، چون آپلود بنر عمومی
|
||||
سایت حساستر از ویرایش برند/برچسب است (custom.config.statics.slider) -->
|
||||
<!-- اسلایدر موبایل — دسترسی جدا (custom.config.statics.slider)؛ سوپرادمین
|
||||
همیشه میبیند حتی اگر نقشش آن rid را نداشته باشد. -->
|
||||
<a-tab-pane
|
||||
v-if="hasPermission('custom.config.statics.slider')"
|
||||
v-if="users.isSuperAdmin || hasPermission('custom.config.statics.slider')"
|
||||
key="slider"
|
||||
tab="اسلایدر موبایل"
|
||||
>
|
||||
@@ -370,7 +370,9 @@ onMounted(async () => {
|
||||
await Promise.all([loadBrands(), users.isSuperAdmin ? loadCollections() : Promise.resolve()]);
|
||||
const [t, s] = await Promise.all([
|
||||
api.get('const/__list__tags'),
|
||||
hasPermission('custom.config.statics.slider') ? api.get('const/slider') : Promise.resolve(null),
|
||||
users.isSuperAdmin || hasPermission('custom.config.statics.slider')
|
||||
? api.get('const/slider')
|
||||
: Promise.resolve(null),
|
||||
]);
|
||||
tags.value = Array.isArray(t.data) ? t.data : [];
|
||||
sliders.value = Array.isArray(s?.data) ? s.data : [];
|
||||
|
||||
@@ -827,6 +827,14 @@ export const treeData: PermissionNode[] = [
|
||||
"key": "config.statics.tags.remove"
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "اسلایدر موبایل",
|
||||
"key": "custom.config.statics.slider"
|
||||
},
|
||||
{
|
||||
"title": "برچسب بنر اول سایت",
|
||||
"key": "custom.config.statics.tags.banner.ids"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -855,19 +863,5 @@ export const treeData: PermissionNode[] = [
|
||||
{
|
||||
"title": "خبرنامه",
|
||||
"key": "newsletters.newsletters",
|
||||
},
|
||||
{
|
||||
"title": "سفارشی",
|
||||
"key": "custom",
|
||||
"children": [
|
||||
{
|
||||
"title": "اسلایدر موبایل",
|
||||
"key": "custom.config.statics.slider"
|
||||
},
|
||||
{
|
||||
"title": "برچسب بنر اول سایت",
|
||||
"key": "custom.config.statics.tags.banner.ids"
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -78,8 +78,11 @@ describe('PermissionsGuard — several rids', () => {
|
||||
});
|
||||
|
||||
describe('withSuperAdminRids', () => {
|
||||
it('adds the super-admin rids for the super admin only', () => {
|
||||
expect(withSuperAdminRids(SUPER_ADMIN_MOBILE, [])).toContain('config.wallet');
|
||||
it('grants every ALL_RIDS entry for the super admin only', () => {
|
||||
const granted = withSuperAdminRids(SUPER_ADMIN_MOBILE, []);
|
||||
expect(granted).toContain('config.wallet');
|
||||
expect(granted).toContain('custom.config.statics.slider');
|
||||
expect(granted.length).toBeGreaterThan(100);
|
||||
expect(withSuperAdminRids('09120000000', ['product.list'])).toEqual(['product.list']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { ALL_RIDS } from './acl.constants';
|
||||
|
||||
/**
|
||||
* The one account allowed to see the super-admin-only features (retail
|
||||
* customers and orders, bankers, walk-in shopkeepers, branches and workshops,
|
||||
@@ -9,8 +11,9 @@ export const SUPER_ADMIN_MOBILE = '09128081392';
|
||||
|
||||
/**
|
||||
* Rids of those features. The admin panel no longer offers them on the
|
||||
* permission screen (except to the super admin), so the super admin is granted
|
||||
* them here whatever its user type holds.
|
||||
* permission screen (except to the super admin). Kept for the permission-tree
|
||||
* filter in the panel; login/JWT grant the full ALL_RIDS set instead (see
|
||||
* withSuperAdminRids) so this phone always sees every gated screen.
|
||||
*/
|
||||
export const SUPER_ADMIN_RIDS = [
|
||||
'persons.create.single',
|
||||
@@ -42,7 +45,10 @@ export function isSuperAdmin(mobile: string | null | undefined): boolean {
|
||||
return mobile?.trim() === SUPER_ADMIN_MOBILE;
|
||||
}
|
||||
|
||||
/** The raw rids an admin holds, plus SUPER_ADMIN_RIDS for the super admin. */
|
||||
/**
|
||||
* For the super-admin mobile, grant every rid in ALL_RIDS (plus any extras
|
||||
* already on the user type). Other admins keep only what their user type holds.
|
||||
*/
|
||||
export function withSuperAdminRids(mobile: string | null | undefined, rids: string[]): string[] {
|
||||
return isSuperAdmin(mobile) ? [...new Set([...rids, ...SUPER_ADMIN_RIDS])] : rids;
|
||||
return isSuperAdmin(mobile) ? [...new Set([...rids, ...ALL_RIDS])] : rids;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user