fix formatting
This commit is contained in:
@ -39,9 +39,9 @@ class LoginForm extends Model
|
||||
protected $securityHelper;
|
||||
|
||||
/**
|
||||
* @param UserQuery $query
|
||||
* @param UserQuery $query
|
||||
* @param SecurityHelper $securityHelper
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(UserQuery $query, SecurityHelper $securityHelper, $config = [])
|
||||
{
|
||||
@ -51,7 +51,7 @@ class LoginForm extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
@ -63,7 +63,7 @@ class LoginForm extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
@ -78,7 +78,7 @@ class LoginForm extends Model
|
||||
) {
|
||||
$this->addError($attribute, Yii::t('user', 'Invalid login or password'));
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
'confirmationValidate' => [
|
||||
'login',
|
||||
@ -93,7 +93,7 @@ class LoginForm extends Model
|
||||
$this->addError($attribute, Yii::t('user', 'Your account has been blocked'));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
'rememberMe' => ['rememberMe', 'boolean'],
|
||||
];
|
||||
@ -108,6 +108,7 @@ class LoginForm extends Model
|
||||
{
|
||||
if ($this->validate()) {
|
||||
$duration = $this->rememberMe ? $this->module->rememberLoginLifespan : 0;
|
||||
|
||||
return Yii::$app->getUser()->login($this->user, $duration);
|
||||
} else {
|
||||
return false;
|
||||
@ -115,14 +116,16 @@ class LoginForm extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function beforeValidate()
|
||||
{
|
||||
if (parent::beforeValidate()) {
|
||||
$this->user = $this->query->whereUsernameOrEmail(trim($this->login))->one();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Form;
|
||||
|
||||
use Da\User\Query\UserQuery;
|
||||
@ -28,7 +29,7 @@ class RecoveryForm extends Model
|
||||
|
||||
/**
|
||||
* @param UserQuery $query
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(UserQuery $query, array $config = [])
|
||||
{
|
||||
@ -37,18 +38,18 @@ class RecoveryForm extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'email' => Yii::t('user', 'Email'),
|
||||
'email' => Yii::t('user', 'Email'),
|
||||
'password' => Yii::t('user', 'Password'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
@ -59,7 +60,7 @@ class RecoveryForm extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
|
||||
@ -8,7 +8,6 @@ use Da\User\Traits\ModuleTrait;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
|
||||
|
||||
class RegistrationForm extends Model
|
||||
{
|
||||
use ModuleTrait;
|
||||
@ -28,7 +27,7 @@ class RegistrationForm extends Model
|
||||
public $password;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
@ -45,7 +44,7 @@ class RegistrationForm extends Model
|
||||
'username',
|
||||
'unique',
|
||||
'targetClass' => $user,
|
||||
'message' => Yii::t('user', 'This username has already been taken')
|
||||
'message' => Yii::t('user', 'This username has already been taken'),
|
||||
],
|
||||
// email rules
|
||||
'emailTrim' => ['email', 'filter', 'filter' => 'trim'],
|
||||
@ -55,7 +54,7 @@ class RegistrationForm extends Model
|
||||
'email',
|
||||
'unique',
|
||||
'targetClass' => $user,
|
||||
'message' => Yii::t('user', 'This email address has already been taken')
|
||||
'message' => Yii::t('user', 'This email address has already been taken'),
|
||||
],
|
||||
// password rules
|
||||
'passwordRequired' => ['password', 'required', 'skipOnEmpty' => $this->module->generatePasswords],
|
||||
@ -64,7 +63,7 @@ class RegistrationForm extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Da\User\Form;
|
||||
|
||||
use Da\User\Query\UserQuery;
|
||||
@ -18,7 +19,7 @@ class ResendForm extends Model
|
||||
|
||||
/**
|
||||
* @param UserQuery $userQuery
|
||||
* @param array $config
|
||||
* @param array $config
|
||||
*/
|
||||
public function __construct(UserQuery $userQuery, $config = [])
|
||||
{
|
||||
@ -27,7 +28,7 @@ class ResendForm extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
@ -38,7 +39,7 @@ class ResendForm extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
|
||||
@ -64,7 +64,7 @@ class SettingsForm extends Model
|
||||
'when' => function ($model, $attribute) {
|
||||
return $this->getUser()->$attribute != $model->$attribute;
|
||||
},
|
||||
'targetClass' => $this->getClassMap()->get(User::class)
|
||||
'targetClass' => $this->getClassMap()->get(User::class),
|
||||
],
|
||||
'newPasswordLength' => ['new_password', 'string', 'max' => 72, 'min' => 6],
|
||||
'currentPasswordRequired' => ['current_password', 'required'],
|
||||
@ -74,13 +74,13 @@ class SettingsForm extends Model
|
||||
if (!$this->securityHelper->validatePassword($this->$attribute, $this->getUser()->password_hash)) {
|
||||
$this->addError($attribute, Yii::t('user', 'Current password is not valid'));
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
@ -117,7 +117,6 @@ class SettingsForm extends Model
|
||||
$this->user->password = $this->new_password;
|
||||
if ($this->email == $this->user->email && $this->user->unconfirmed_email != null) {
|
||||
$this->user->unconfirmed_email = null;
|
||||
|
||||
} elseif ($this->email != $this->user->email) {
|
||||
$strategy = EmailChangeStrategyFactory::makeByStrategyType(
|
||||
$this->getModule()->emailChangeStrategy,
|
||||
|
||||
Reference in New Issue
Block a user