add status to login method
This commit is contained in:
parent
06cfa93adf
commit
f5e69511fb
@ -23,6 +23,8 @@ use yii\web\UnauthorizedHttpException;
|
|||||||
* @property integer $updated_at
|
* @property integer $updated_at
|
||||||
* @property $access_token_expired_at
|
* @property $access_token_expired_at
|
||||||
* @property string $password write-only password
|
* @property string $password write-only password
|
||||||
|
*
|
||||||
|
* @property UserCard $userCard
|
||||||
*/
|
*/
|
||||||
class User extends ActiveRecord implements IdentityInterface, UserRbacInterface
|
class User extends ActiveRecord implements IdentityInterface, UserRbacInterface
|
||||||
{
|
{
|
||||||
|
@ -62,12 +62,14 @@ class UserController extends ActiveController
|
|||||||
{
|
{
|
||||||
$model = new LoginForm();
|
$model = new LoginForm();
|
||||||
if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->login()) {
|
if ($model->load(Yii::$app->getRequest()->getBodyParams(), '') && $model->login()) {
|
||||||
|
/** @var User $user */
|
||||||
|
$user = $model->getUser();
|
||||||
return [
|
return [
|
||||||
'access_token' => $model->login(),
|
'access_token' => $model->login(),
|
||||||
'access_token_expired_at' => $model->getUser()->getTokenExpiredAt(),
|
'access_token_expired_at' => $model->getUser()->getTokenExpiredAt(),
|
||||||
'id' => $model->getUser()->id,
|
'id' => $user->id,
|
||||||
'status' => $model->getUser()->status,
|
'status' => $user->userCard->status,
|
||||||
'card_id' => $model->getUser()->userCard->id ?? null,
|
'card_id' => $user->userCard->id ?? null,
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestHttpException(json_encode($model->errors));
|
throw new BadRequestHttpException(json_encode($model->errors));
|
||||||
|
Loading…
Reference in New Issue
Block a user