mirror of
https://github.com/elyby/accounts.git
synced 2024-11-30 02:32:26 +05:30
Merge branch 'forgot_password_captcha' into develop
This commit is contained in:
commit
b9df9ff2a7
@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace api\models\authentication;
|
namespace api\models\authentication;
|
||||||
|
|
||||||
use common\emails\EmailHelper;
|
use api\components\ReCaptcha\Validator as ReCaptchaValidator;
|
||||||
use api\models\base\ApiForm;
|
use api\models\base\ApiForm;
|
||||||
use api\validators\TotpValidator;
|
use api\validators\TotpValidator;
|
||||||
|
use common\emails\EmailHelper;
|
||||||
use common\helpers\Error as E;
|
use common\helpers\Error as E;
|
||||||
use api\traits\AccountFinder;
|
use api\traits\AccountFinder;
|
||||||
use common\components\UserFriendlyRandomKey;
|
use common\components\UserFriendlyRandomKey;
|
||||||
@ -15,11 +16,15 @@ use yii\base\ErrorException;
|
|||||||
class ForgotPasswordForm extends ApiForm {
|
class ForgotPasswordForm extends ApiForm {
|
||||||
use AccountFinder;
|
use AccountFinder;
|
||||||
|
|
||||||
|
public $captcha;
|
||||||
|
|
||||||
public $login;
|
public $login;
|
||||||
|
|
||||||
public $token;
|
public $token;
|
||||||
|
|
||||||
public function rules() {
|
public function rules() {
|
||||||
return [
|
return [
|
||||||
|
['captcha', ReCaptchaValidator::class],
|
||||||
['login', 'required', 'message' => E::LOGIN_REQUIRED],
|
['login', 'required', 'message' => E::LOGIN_REQUIRED],
|
||||||
['login', 'validateLogin'],
|
['login', 'validateLogin'],
|
||||||
['token', 'required', 'when' => function(self $model) {
|
['token', 'required', 'when' => function(self $model) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace codeception\api\unit\models\authentication;
|
namespace codeception\api\unit\models\authentication;
|
||||||
|
|
||||||
|
use api\components\ReCaptcha\Validator as ReCaptchaValidator;
|
||||||
use api\models\authentication\ForgotPasswordForm;
|
use api\models\authentication\ForgotPasswordForm;
|
||||||
use Codeception\Specify;
|
use Codeception\Specify;
|
||||||
use common\models\EmailActivation;
|
use common\models\EmailActivation;
|
||||||
@ -8,10 +9,20 @@ use OTPHP\TOTP;
|
|||||||
use tests\codeception\api\unit\TestCase;
|
use tests\codeception\api\unit\TestCase;
|
||||||
use tests\codeception\common\fixtures\AccountFixture;
|
use tests\codeception\common\fixtures\AccountFixture;
|
||||||
use tests\codeception\common\fixtures\EmailActivationFixture;
|
use tests\codeception\common\fixtures\EmailActivationFixture;
|
||||||
|
use Yii;
|
||||||
|
|
||||||
class ForgotPasswordFormTest extends TestCase {
|
class ForgotPasswordFormTest extends TestCase {
|
||||||
use Specify;
|
use Specify;
|
||||||
|
|
||||||
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
|
Yii::$container->set(ReCaptchaValidator::class, new class extends ReCaptchaValidator {
|
||||||
|
public function validateValue($value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function _fixtures() {
|
public function _fixtures() {
|
||||||
return [
|
return [
|
||||||
'accounts' => AccountFixture::class,
|
'accounts' => AccountFixture::class,
|
||||||
|
Loading…
Reference in New Issue
Block a user