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
+5 -2
View File
@@ -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']);
});
});
+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
* 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;
}