Skip to content

feat(access): can() fallback to SecurityPrincipal getRoles()#397

Merged
usernane merged 1 commit into
devfrom
feat/access-can-fallback
Jun 14, 2026
Merged

feat(access): can() fallback to SecurityPrincipal getRoles()#397
usernane merged 1 commit into
devfrom
feat/access-can-fallback

Conversation

@usernane

Copy link
Copy Markdown
Member

Summary

When the internal role map is empty for a user, can() falls back to $user->getRoles().

Changes

  • 4-line addition in AccessManager::can()
  • 2 tests: fallback works, internal map still takes precedence

Related issues

Closes #381

When the internal userRoles map is empty for a user, can() now
checks if the user object has a getRoles() method and uses those
roles. Internal map still takes precedence when populated.

Closes #381
@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.75%. Comparing base (b982bd6) to head (a041a41).
⚠️ Report is 6 commits behind head on dev.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev     #397      +/-   ##
============================================
+ Coverage     83.67%   83.75%   +0.08%     
- Complexity     3067     3086      +19     
============================================
  Files           103      104       +1     
  Lines          9018     9063      +45     
============================================
+ Hits           7546     7591      +45     
  Misses         1472     1472              
Flag Coverage Δ
php-8.1 82.63% <ø> (+0.03%) ⬆️
php-8.2 82.63% <ø> (+0.03%) ⬆️
php-8.3 92.13% <100.00%> (+0.04%) ⬆️
php-8.4 92.13% <100.00%> (+0.04%) ⬆️
php-8.5 92.00% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

@usernane usernane merged commit fecea28 into dev Jun 14, 2026
16 checks passed
@usernane usernane deleted the feat/access-can-fallback branch June 14, 2026 10:50
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