Skip to content

fix: undefined permissions bug#90

Closed
mukama wants to merge 1 commit into
tetherto:developfrom
mukama:fix/auth-perms-match
Closed

fix: undefined permissions bug#90
mukama wants to merge 1 commit into
tetherto:developfrom
mukama:fix/auth-perms-match

Conversation

@mukama
Copy link
Copy Markdown
Contributor

@mukama mukama commented Jun 4, 2026

Summary

  • Bug: tokenHasPerms passes bare resource names (e.g. 'work_order') from route perms to _permsMatch, which expects resource:level format. Splitting a bare name by : leaves required as undefined, and [...undefined] throws TypeError: required is not iterable.
  • Impact: All permission-gated routes that use the perms parameter — currently work-orders and spare-parts endpoints — crash on staging with this error on every request.
  • Fix: In tokenHasPerms, auto-append the level suffix (rw for write routes, r for read) when a perm string doesn't contain :. Already-qualified perms pass through unchanged.

tokenHasPerms received bare resource names (e.g. 'work_order') from
route perms, but _permsMatch expects 'resource:level' format. Splitting
a bare name by ':' left `required` as undefined, crashing on spread.
@mukama mukama self-assigned this Jun 4, 2026
@mukama mukama changed the title fix: auto-qualify bare permission names in tokenHasPerms fix: permissions access levels bug Jun 4, 2026
@mukama mukama changed the title fix: permissions access levels bug fix: undefined permissions bug Jun 4, 2026
@mukama
Copy link
Copy Markdown
Contributor Author

mukama commented Jun 4, 2026

Combined into #88

@mukama mukama closed this Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant