From 7ae44e1acd54480630d31a714df3c247e30b48da Mon Sep 17 00:00:00 2001 From: Andres Campanario Date: Wed, 19 Nov 2025 15:24:32 +0100 Subject: [PATCH] check user returned to convert if is necessary before pass to _afterIdentifyUser --- src/Service/Action/Auth/LoginAction.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Service/Action/Auth/LoginAction.php b/src/Service/Action/Auth/LoginAction.php index 2520b9b..aa33ade 100644 --- a/src/Service/Action/Auth/LoginAction.php +++ b/src/Service/Action/Auth/LoginAction.php @@ -19,6 +19,8 @@ use CakeDC\Api\Service\Action\Action; use CakeDC\Users\Controller\Traits\LoginTrait; use CakeDC\Users\Exception\UserNotFoundException; +use Authentication\IdentityInterface; +use Cake\Datasource\EntityInterface; /** * Class LoginAction @@ -82,6 +84,14 @@ public function execute() { $socialLogin = false; $user = $this->Auth->getIdentity(); + + if ($user instanceof IdentityInterface) { + $user = $user->getOriginalData()->toArray(); + } + if ($user instanceof EntityInterface) { + $user = $user->toArray(); + } + $user = $this->_afterIdentifyUser($user, $socialLogin); if (empty($user)) { throw new UserNotFoundException(__d('CakeDC/Api', 'User not found'), 401);