Добавлен обработчик для удаления сессии при логауте

This commit is contained in:
ErickSkrauch
2016-07-17 19:38:04 +03:00
parent 2063d7daa0
commit ae3c3b88de
5 changed files with 128 additions and 0 deletions

View File

@ -3,6 +3,7 @@ namespace api\controllers;
use api\models\authentication\ForgotPasswordForm;
use api\models\authentication\LoginForm;
use api\models\authentication\LogoutForm;
use api\models\authentication\RecoverPasswordForm;
use api\models\authentication\RefreshTokenForm;
use common\helpers\Error as E;
@ -26,6 +27,11 @@ class AuthenticationController extends Controller {
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['logout'],
'allow' => true,
'roles' => ['@'],
],
],
],
]);
@ -34,6 +40,7 @@ class AuthenticationController extends Controller {
public function verbs() {
return [
'login' => ['POST'],
'logout' => ['POST'],
'forgot-password' => ['POST'],
'recover-password' => ['POST'],
'refresh-token' => ['POST'],
@ -61,6 +68,15 @@ class AuthenticationController extends Controller {
], $result->getAsResponse());
}
public function actionLogout() {
$form = new LogoutForm();
$form->logout();
return [
'success' => true,
];
}
public function actionForgotPassword() {
$model = new ForgotPasswordForm();
$model->load(Yii::$app->request->post());