fix login

This commit is contained in:
Kavalar 2023-10-12 10:45:39 +03:00
parent c691273d02
commit 03b25a796d
2 changed files with 15 additions and 6 deletions

View File

@ -18,8 +18,14 @@ class UserController extends ApiController
{ {
public $modelClass = User::class; 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(), [ // return ArrayHelper::merge(parent::behaviors(), [
// [ // [
// 'class' => ContentNegotiator::class, // 'class' => ContentNegotiator::class,
@ -42,7 +48,7 @@ class UserController extends ApiController
// ] // ]
// ], // ],
// ]); // ]);
// } }
public function actions() public function actions()
{ {
@ -69,7 +75,7 @@ class UserController extends ApiController
'access_token' => $model->login(), 'access_token' => $model->login(),
'access_token_expired_at' => $model->getUser()->getTokenExpiredAt(), 'access_token_expired_at' => $model->getUser()->getTokenExpiredAt(),
'id' => $user->id, 'id' => $user->id,
'status' => $user->userCard->status, 'status' => $user->userCard->status ?? null,
'card_id' => $user->userCard->id ?? null, 'card_id' => $user->userCard->id ?? null,
]; ];
} else { } else {

View File

@ -17,9 +17,12 @@ class User extends \common\models\User
'email', 'email',
'username', 'username',
'userCard' => function () { 'userCard' => function () {
$userCard = new UserCardSearch(); if(isset($this->userCard->id)){
return ProfileService::getProfileById($this->userCard->id); return ProfileService::getProfileById($this->userCard->id);
} }
return null;
}
]; ];
} }