mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Реорганизована выдача JWT токенов
Добавлен механизм сохранения сессий и refresh_token
This commit is contained in:
@ -40,7 +40,7 @@ class AuthenticationController extends Controller {
|
||||
public function actionLogin() {
|
||||
$model = new LoginForm();
|
||||
$model->load(Yii::$app->request->post());
|
||||
if (($jwt = $model->login()) === false) {
|
||||
if (($result = $model->login()) === false) {
|
||||
$data = [
|
||||
'success' => false,
|
||||
'errors' => $this->normalizeModelErrors($model->getErrors()),
|
||||
@ -53,10 +53,9 @@ class AuthenticationController extends Controller {
|
||||
return $data;
|
||||
}
|
||||
|
||||
return [
|
||||
return array_merge([
|
||||
'success' => true,
|
||||
'jwt' => $jwt,
|
||||
];
|
||||
], $result->getAsResponse());
|
||||
}
|
||||
|
||||
public function actionForgotPassword() {
|
||||
@ -98,17 +97,16 @@ class AuthenticationController extends Controller {
|
||||
public function actionRecoverPassword() {
|
||||
$model = new RecoverPasswordForm();
|
||||
$model->load(Yii::$app->request->post());
|
||||
if (($jwt = $model->recoverPassword()) === false) {
|
||||
if (($result = $model->recoverPassword()) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'errors' => $this->normalizeModelErrors($model->getErrors()),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
return array_merge([
|
||||
'success' => true,
|
||||
'jwt' => $jwt,
|
||||
];
|
||||
], $result->getAsResponse());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ class Controller extends \yii\rest\Controller {
|
||||
$parentBehaviors = parent::behaviors();
|
||||
// Добавляем авторизатор для входа по jwt токенам
|
||||
$parentBehaviors['authenticator'] = [
|
||||
'class' => HttpBearerAuth::className(),
|
||||
'class' => HttpBearerAuth::class,
|
||||
];
|
||||
|
||||
// xml нам не понадобится
|
||||
|
@ -79,17 +79,16 @@ class SignupController extends Controller {
|
||||
public function actionConfirm() {
|
||||
$model = new ConfirmEmailForm();
|
||||
$model->load(Yii::$app->request->post());
|
||||
if (!($jwt = $model->confirm())) {
|
||||
if (!($result = $model->confirm())) {
|
||||
return [
|
||||
'success' => false,
|
||||
'errors' => $this->normalizeModelErrors($model->getErrors()),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
return array_merge([
|
||||
'success' => true,
|
||||
'jwt' => $jwt,
|
||||
];
|
||||
], $result->getAsResponse());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user