Extract login logics into a separate component. Not quite clean result but enough for upcoming tasks

This commit is contained in:
ErickSkrauch
2025-01-17 21:37:35 +01:00
parent 1c2969a4be
commit be4697e6eb
39 changed files with 443 additions and 729 deletions

View File

@@ -7,7 +7,7 @@ use api\controllers\Controller;
use api\modules\authserver\models;
use Yii;
class AuthenticationController extends Controller {
final class AuthenticationController extends Controller {
public function behaviors(): array {
$behaviors = parent::behaviors();
@@ -27,12 +27,11 @@ class AuthenticationController extends Controller {
}
/**
* @return array
* @throws \api\modules\authserver\exceptions\ForbiddenOperationException
* @throws \api\modules\authserver\exceptions\IllegalArgumentException
*/
public function actionAuthenticate(): array {
$model = new models\AuthenticationForm();
/** @var \api\modules\authserver\models\AuthenticationForm $model */
$model = Yii::createObject(models\AuthenticationForm::class);
$model->load(Yii::$app->request->post());
return $model->authenticate()->getResponseData(true);
@@ -62,10 +61,6 @@ class AuthenticationController extends Controller {
// In case of an error, an exception is thrown which will be processed by ErrorHandler
}
/**
* @throws \api\modules\authserver\exceptions\ForbiddenOperationException
* @throws \api\modules\authserver\exceptions\IllegalArgumentException
*/
public function actionSignout(): void {
$model = new models\SignoutForm();
$model->load(Yii::$app->request->post());