Backend: RBAC faza 2 M1 - role gymowe z grantow zamiast kolumny roles (migracja: seed GYM_OWNER/GYM_TRAINER + backfill grantow i uzupelnienie Coaching.gymId; katalog 11 uprawnien gym z pinem gym:delegate tylko dla wlasciciela; resolver lib/gymPermissions i bramy per zasob w uslugach silowni, feedzie, obecnosciach i kontaktach; CRUD rol custom per silownia z kluczem serwerowym + PUT ról czlonka pod /admin/gyms; rekrutacja trenera wymaga wspolnej silowni (Coaching.gymId, 0 lub wiele = 400); DTO roles wyprowadzane z grantow - kolumna roles martwa do M4; wyszukiwanie admina po e-mailu wymaga pii:read; 15 unit testow resolvera, zestaw api 1009 green)
This commit is contained in:
@@ -3,6 +3,7 @@ import { prisma } from '../../src/lib/prisma.js';
|
||||
import {
|
||||
buildApp,
|
||||
createUser,
|
||||
grantGymRole,
|
||||
loginViaApi,
|
||||
rand,
|
||||
registerViaApi,
|
||||
@@ -222,10 +223,7 @@ describe('admin routes', () => {
|
||||
expect(byQ.body.total).toBe(1);
|
||||
|
||||
// filtr roli: kadra (TRAINER) i OWNER — bez mieszania ról
|
||||
await prisma.gymMembership.update({
|
||||
where: { userId_gymId: { userId: member2.id, gymId: gym } },
|
||||
data: { roles: ['MEMBER', 'TRAINER'] },
|
||||
});
|
||||
await grantGymRole(member2.id, gym, 'GYM_TRAINER');
|
||||
const byTrainer = await app
|
||||
.get(`/api/v1/admin/gyms/${gym}/members?role=TRAINER`)
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
@@ -333,10 +331,10 @@ describe('admin routes', () => {
|
||||
countryCode: 'PL',
|
||||
capacity: 50,
|
||||
});
|
||||
const membership = await prisma.gymMembership.findUnique({
|
||||
where: { userId_gymId: { userId: ownerId, gymId: newGymId } },
|
||||
const ownerGrant = await prisma.userRoleGrant.findFirst({
|
||||
where: { userId: ownerId, gymId: newGymId, role: { key: 'GYM_OWNER' } },
|
||||
});
|
||||
expect(membership?.roles).toEqual(['OWNER']);
|
||||
expect(ownerGrant).not.toBeNull();
|
||||
const detail = await app
|
||||
.get(`/api/v1/admin/gyms/${newGymId}`)
|
||||
.set('Authorization', `Bearer ${adminToken}`);
|
||||
|
||||
Reference in New Issue
Block a user