Skip to content

Commit 4f77599

Browse files
authored
Merge pull request #121 from ACampanario/feature/41789
check user returned to convert if is necessary before pass to _afterI…
2 parents e4380bb + 7ae44e1 commit 4f77599

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Service/Action/Auth/LoginAction.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use CakeDC\Api\Service\Action\Action;
2020
use CakeDC\Users\Controller\Traits\LoginTrait;
2121
use CakeDC\Users\Exception\UserNotFoundException;
22+
use Authentication\IdentityInterface;
23+
use Cake\Datasource\EntityInterface;
2224

2325
/**
2426
* Class LoginAction
@@ -82,6 +84,14 @@ public function execute()
8284
{
8385
$socialLogin = false;
8486
$user = $this->Auth->getIdentity();
87+
88+
if ($user instanceof IdentityInterface) {
89+
$user = $user->getOriginalData()->toArray();
90+
}
91+
if ($user instanceof EntityInterface) {
92+
$user = $user->toArray();
93+
}
94+
8595
$user = $this->_afterIdentifyUser($user, $socialLogin);
8696
if (empty($user)) {
8797
throw new UserNotFoundException(__d('CakeDC/Api', 'User not found'), 401);

0 commit comments

Comments
 (0)