mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлена аннотация для сбора метрик из моделей Yii2 и интегрирована в формы авторизации и регистрации
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
@@ -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;
|
||||
|
@@ -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() {
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -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() {
|
||||
|
@@ -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
|
||||
*/
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user