paultofunmi opened a new pull request, #145:
URL: https://github.com/apache/fineract-backoffice-ui/pull/145
Fixes a class of silent permission-check failures caused by trailing-space
duplicates in Fineract's backend permission data (e.g.
`"CREATE_STANDINGINSTRUCTION"` vs `"CREATE_STANDINGINSTRUCTION "`).
`AuthService.hasPermission()` does exact string matching, so a clean
requirement string would fail to match if the backend only returned the dirty
variant for a given role — the gated UI element stays hidden even though the
user actually has the permission.
Discovered while gating Standing Instructions nav items in #142.
## Changes
- **`src/app/core/services/auth.service.ts`** — added a private
`normalizePermissions()` helper (trim each code, dedupe via `Set`), applied in:
- `setSession()` — normalizes a fresh login response before persisting to
`sessionStorage`/the signal
- `getStoredSession()` — normalizes on read from `sessionStorage`, so
sessions already open in a user's browser before this fix ships also
self-correct, without needing to log out/in
- **`src/app/core/services/auth.service.spec.ts`** — 3 new tests: trims a
trailing-space permission on `setSession`, dedupes a clean/dirty duplicate
pair, and normalizes a dirty session read back from `sessionStorage` on fresh
construction (via `TestBed.resetTestingModule()` to genuinely exercise
`getStoredSession()`, not just re-inject the same instance)
## Why fix it here, not per call-site
`user.permissions` is read in exactly one place in the codebase —
`AuthService.hasPermission()` (verified via grep). Fixing normalization at the
single ingestion point means every consumer (`*appHasPermission`,
`NavigationConfigService`) is correct automatically, with zero changes needed
anywhere else.
## Testing
- Unit: `npm test -- --watch=false` — 565/565 passing (3 new)
- Lint: `npm run lint` — clean
- Format: `npm run format:check` — clean
## Out of scope
- Not fixing Fineract's backend seed data itself (server-side, different
repo)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]