Skip to content

"Call to a member function getOriginalData() on null" Cake4 - RequestAuthorizationMiddleware #150

@ghost

Description

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 4.1.0

I followed the implementation of the Request Authorization Middleware : https://book.cakephp.org/authorization/2/en/request-authorization-middleware.html
My objective is to setup a global security by checking the user role. So i created a RequestPolicy.php with the function canAccess.
It works well however when the session is expired, it still calls the function canAccess which uses $identity which is null because of the expired session so i get an error “Call to a member function getOriginalData() on null” ($identity->getOriginalData()) instead of redirecting me to the login with the redirect param.
I do not understand how it is supposed to handle that case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions