From 03b25a796d8ef878c308ae7d7e9703adc98b96b2 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Thu, 12 Oct 2023 10:45:39 +0300 Subject: [PATCH] fix login --- .../modules/api/controllers/UserController.php | 14 ++++++++++---- frontend/modules/api/models/User.php | 7 +++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/modules/api/controllers/UserController.php b/frontend/modules/api/controllers/UserController.php index d0124e1..98b6bb8 100755 --- a/frontend/modules/api/controllers/UserController.php +++ b/frontend/modules/api/controllers/UserController.php @@ -18,8 +18,14 @@ class UserController extends ApiController { public $modelClass = User::class; -// public function behaviors() -// { + public function behaviors() + { + $behaviors = parent::behaviors(); + if($this->action->id == "login"){ + unset($behaviors['authenticator']); + } + + return $behaviors; // return ArrayHelper::merge(parent::behaviors(), [ // [ // 'class' => ContentNegotiator::class, @@ -42,7 +48,7 @@ class UserController extends ApiController // ] // ], // ]); -// } + } public function actions() { @@ -69,7 +75,7 @@ class UserController extends ApiController 'access_token' => $model->login(), 'access_token_expired_at' => $model->getUser()->getTokenExpiredAt(), 'id' => $user->id, - 'status' => $user->userCard->status, + 'status' => $user->userCard->status ?? null, 'card_id' => $user->userCard->id ?? null, ]; } else { diff --git a/frontend/modules/api/models/User.php b/frontend/modules/api/models/User.php index d9ca54b..acd5fda 100644 --- a/frontend/modules/api/models/User.php +++ b/frontend/modules/api/models/User.php @@ -17,8 +17,11 @@ class User extends \common\models\User 'email', 'username', 'userCard' => function () { - $userCard = new UserCardSearch(); - return ProfileService::getProfileById($this->userCard->id); + if(isset($this->userCard->id)){ + return ProfileService::getProfileById($this->userCard->id); + } + + return null; } ]; }