Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #481 #482

Closed
wants to merge 2 commits into from
Closed

fixes #481 #482

wants to merge 2 commits into from

Conversation

bilogic
Copy link
Contributor

@bilogic bilogic commented Jan 5, 2025

fixes #481 prevent exception by indicating that user() can be null

Copy link

what-the-diff bot commented Jan 5, 2025

PR Summary

  • Improved Safety in 'canAccess' Method
    The canAccess method within our HasPageShield code has been updated to more effectively handle scenarios when the user is undefined or null. This prevents possible system errors or mishandling.

  • Updated 'canView' Method for Better Null Handling
    The canView method in the HasWidgetShield portion of our code has also been updated. It now uses a technique known as the null-safe operator, which makes our application more resilient in cases where the user might not be defined or null.

@bezhanSalleh
Copy link
Owner

If you’re using Shield’s traits for guest pages and the panel, keep this in mind:

Shield provides traits to kickstart handling common scenarios. But, handling every unique use case isn’t its job—it’s near impossible.

To customize for your project, create traits specific to your needs and apply them to guest pages/widgets.

@bilogic
Copy link
Contributor Author

bilogic commented Jan 8, 2025

I'm not using it for any guest pages

@bilogic
Copy link
Contributor Author

bilogic commented Jan 19, 2025

@bezhanSalleh

  1. https://github.com/illuminate/contracts/blob/4ce27a82391dd3050e85fe38ae50bc61dd8ece46/Auth/Guard.php#L21-L26
    • user() can return Authenticatable or null
  2. The traits assume user() will always be Authenticatable and throws exceptions when null is returned
  3. The traits break when the panels use ->login(null)
  4. Please kindly accept this PR so that using ->login(null) won't cause exceptions

Thank you.

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.

Exception when logging out
2 participants