Добавлена аннотация для сбора метрик из моделей Yii2 и интегрирована в формы авторизации и регистрации

This commit is contained in:
ErickSkrauch
2017-11-19 18:32:51 +03:00
parent 236f0e7d50
commit 63db3adca9
11 changed files with 90 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
<?php
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;
use api\models\base\ApiForm;
use api\modules\accounts\models\ChangeUsernameForm;
use api\validators\EmailActivationKeyValidator;
@@ -20,6 +21,7 @@ class ConfirmEmailForm extends ApiForm {
}
/**
* @CollectModelMetrics(prefix="signup.confirmEmail")
* @return \api\components\User\AuthenticationResult|bool
* @throws ErrorException
*/

View File

@@ -1,6 +1,7 @@
<?php
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;
use api\components\ReCaptcha\Validator as ReCaptchaValidator;
use api\models\base\ApiForm;
use common\emails\EmailHelper;
@@ -55,6 +56,11 @@ class ForgotPasswordForm extends ApiForm {
}
}
/**
* @CollectModelMetrics(prefix="authentication.forgotPassword")
* @return bool
* @throws ErrorException
*/
public function forgotPassword() {
if (!$this->validate()) {
return false;

View File

@@ -1,6 +1,7 @@
<?php
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;
use api\models\base\ApiForm;
use api\validators\TotpValidator;
use common\helpers\Error as E;
@@ -87,6 +88,7 @@ class LoginForm extends ApiForm {
}
/**
* @CollectModelMetrics(prefix="authentication.login")
* @return \api\components\User\AuthenticationResult|bool
*/
public function login() {

View File

@@ -1,12 +1,18 @@
<?php
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;
use api\models\base\ApiForm;
use Yii;
class LogoutForm extends ApiForm {
/**
* @CollectModelMetrics(prefix="authentication.logout")
* @return bool
*/
public function logout() : bool {
$component = \Yii::$app->user;
$component = Yii::$app->user;
$session = $component->getActiveSession();
if ($session === null) {
return true;

View File

@@ -1,6 +1,7 @@
<?php
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;
use api\models\base\ApiForm;
use api\validators\EmailActivationKeyValidator;
use common\helpers\Error as E;
@@ -36,6 +37,7 @@ class RecoverPasswordForm extends ApiForm {
}
/**
* @CollectModelMetrics(prefix="authentication.recoverPassword")
* @return \api\components\User\AuthenticationResult|bool
* @throws ErrorException
*/

View File

@@ -1,6 +1,7 @@
<?php
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;
use api\models\base\ApiForm;
use common\helpers\Error as E;
use common\models\AccountSession;
@@ -32,6 +33,7 @@ class RefreshTokenForm extends ApiForm {
}
/**
* @CollectModelMetrics(prefix="authentication.renew")
* @return \api\components\User\AuthenticationResult|bool
*/
public function renew() {

View File

@@ -1,6 +1,7 @@
<?php
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;
use api\components\ReCaptcha\Validator as ReCaptchaValidator;
use common\emails\EmailHelper;
use api\models\base\ApiForm;
@@ -63,6 +64,7 @@ class RegistrationForm extends ApiForm {
}
/**
* @CollectModelMetrics(prefix="signup.register")
* @return Account|null the saved model or null if saving fails
* @throws Exception
*/

View File

@@ -1,6 +1,7 @@
<?php
namespace api\models\authentication;
use api\aop\annotations\CollectModelMetrics;
use api\components\ReCaptcha\Validator as ReCaptchaValidator;
use common\emails\EmailHelper;
use api\models\base\ApiForm;
@@ -53,6 +54,11 @@ class RepeatAccountActivationForm extends ApiForm {
}
}
/**
* @CollectModelMetrics(prefix="signup.repeatEmail")
* @return bool
* @throws ErrorException
*/
public function sendRepeatMessage() {
if (!$this->validate()) {
return false;