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:
s.esmaeili
2026-10-16 09:27:41 +03:30
co-authored by Cursor
parent 1dd66a1baf
commit eb6fe2a369
5 changed files with 31 additions and 24 deletions
+2
View File
@@ -6,6 +6,8 @@
* gated by `users.isSuperAdmin` in place instead. * gated by `users.isSuperAdmin` in place instead.
* *
* Keep in step with SUPER_ADMIN_RIDS in apps/api/src/modules/auth/super-admin.ts. * 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([ export const SUPER_ADMIN_RIDS: ReadonlySet<string> = new Set([
'persons.create.single', 'persons.create.single',
+6 -4
View File
@@ -94,10 +94,10 @@
<a-button class="mt-4" type="primary" @click="saveTags">ذخیره برچسب ها</a-button> <a-button class="mt-4" type="primary" @click="saveTags">ذخیره برچسب ها</a-button>
</a-tab-pane> </a-tab-pane>
<!-- اسلایدر موبایل — دسترسی جدا از بقیه‌ی این صفحه، چون آپلود بنر عمومی <!-- اسلایدر موبایل — دسترسی جدا (custom.config.statics.slider)؛ سوپرادمین
سایت حساس‌تر از ویرایش برند/برچسب است (custom.config.statics.slider) --> همیشه می‌بیند حتی اگر نقشش آن rid را نداشته باشد. -->
<a-tab-pane <a-tab-pane
v-if="hasPermission('custom.config.statics.slider')" v-if="users.isSuperAdmin || hasPermission('custom.config.statics.slider')"
key="slider" key="slider"
tab="اسلایدر موبایل" tab="اسلایدر موبایل"
> >
@@ -370,7 +370,9 @@ onMounted(async () => {
await Promise.all([loadBrands(), users.isSuperAdmin ? loadCollections() : Promise.resolve()]); await Promise.all([loadBrands(), users.isSuperAdmin ? loadCollections() : Promise.resolve()]);
const [t, s] = await Promise.all([ const [t, s] = await Promise.all([
api.get('const/__list__tags'), 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 : []; tags.value = Array.isArray(t.data) ? t.data : [];
sliders.value = Array.isArray(s?.data) ? s.data : []; sliders.value = Array.isArray(s?.data) ? s.data : [];
@@ -827,6 +827,14 @@ export const treeData: PermissionNode[] = [
"key": "config.statics.tags.remove" "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": "خبرنامه", "title": "خبرنامه",
"key": "newsletters.newsletters", "key": "newsletters.newsletters",
},
{
"title": "سفارشی",
"key": "custom",
"children": [
{
"title": "اسلایدر موبایل",
"key": "custom.config.statics.slider"
},
{
"title": "برچسب بنر اول سایت",
"key": "custom.config.statics.tags.banner.ids"
},
]
} }
] ]
+5 -2
View File
@@ -78,8 +78,11 @@ describe('PermissionsGuard — several rids', () => {
}); });
describe('withSuperAdminRids', () => { describe('withSuperAdminRids', () => {
it('adds the super-admin rids for the super admin only', () => { it('grants every ALL_RIDS entry for the super admin only', () => {
expect(withSuperAdminRids(SUPER_ADMIN_MOBILE, [])).toContain('config.wallet'); 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']); expect(withSuperAdminRids('09120000000', ['product.list'])).toEqual(['product.list']);
}); });
}); });
+10 -4
View File
@@ -1,3 +1,5 @@
import { ALL_RIDS } from './acl.constants';
/** /**
* The one account allowed to see the super-admin-only features (retail * The one account allowed to see the super-admin-only features (retail
* customers and orders, bankers, walk-in shopkeepers, branches and workshops, * 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 * 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 * permission screen (except to the super admin). Kept for the permission-tree
* them here whatever its user type holds. * 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 = [ export const SUPER_ADMIN_RIDS = [
'persons.create.single', 'persons.create.single',
@@ -42,7 +45,10 @@ export function isSuperAdmin(mobile: string | null | undefined): boolean {
return mobile?.trim() === SUPER_ADMIN_MOBILE; 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[] { 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;
} }