mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Реализованы формы для шагов смены E-mail адреса, покрыты unit-тестами
У EmailActivation добавлено поле $_data и дописано поведение для работы с ним Упрощено подключение фикстур для EmailActivations
This commit is contained in:
23
common/models/confirmations/CurrentEmailConfirmation.php
Normal file
23
common/models/confirmations/CurrentEmailConfirmation.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace common\models\confirmations;
|
||||
|
||||
use common\models\EmailActivation;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
class CurrentEmailConfirmation extends EmailActivation {
|
||||
|
||||
public function behaviors() {
|
||||
return ArrayHelper::merge(parent::behaviors(), [
|
||||
'expirationBehavior' => [
|
||||
'repeatTimeout' => 6 * 60 * 60,
|
||||
'expirationTimeout' => 1 * 60 * 60,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
$this->type = EmailActivation::TYPE_CURRENT_EMAIL_CONFIRMATION;
|
||||
}
|
||||
|
||||
}
|
29
common/models/confirmations/NewEmailConfirmation.php
Normal file
29
common/models/confirmations/NewEmailConfirmation.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace common\models\confirmations;
|
||||
|
||||
use common\models\EmailActivation;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* Поведения:
|
||||
* @mixin NewEmailConfirmationBehavior
|
||||
*/
|
||||
class NewEmailConfirmation extends EmailActivation {
|
||||
|
||||
public function behaviors() {
|
||||
return ArrayHelper::merge(parent::behaviors(), [
|
||||
'expirationBehavior' => [
|
||||
'repeatTimeout' => 5 * 60,
|
||||
],
|
||||
'dataBehavior' => [
|
||||
'class' => NewEmailConfirmationBehavior::class,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
$this->type = EmailActivation::TYPE_NEW_EMAIL_CONFIRMATION;
|
||||
}
|
||||
|
||||
}
|
19
common/models/confirmations/NewEmailConfirmationBehavior.php
Normal file
19
common/models/confirmations/NewEmailConfirmationBehavior.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace common\models\confirmations;
|
||||
|
||||
use common\behaviors\DataBehavior;
|
||||
|
||||
/**
|
||||
* @property string $newEmail
|
||||
*/
|
||||
class NewEmailConfirmationBehavior extends DataBehavior {
|
||||
|
||||
public function getNewEmail() : string {
|
||||
return $this->getKey('newEmail');
|
||||
}
|
||||
|
||||
public function setNewEmail(string $newEmail) {
|
||||
$this->setKey('newEmail', $newEmail);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user