本文整理汇总了PHP中app\models\User::findByPasswordResetToken方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findByPasswordResetToken方法的具体用法?PHP User::findByPasswordResetToken怎么用?PHP User::findByPasswordResetToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::findByPasswordResetToken方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a form model given a token.
*
* @param string $token
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if token is empty or not valid
*/
public function __construct($token, $config = [])
{
if ($token === '') {
throw new InvalidParamException('Токен для сброса пароля не может быть пустым');
}
if (!($this->_user = User::findByPasswordResetToken($token))) {
throw new InvalidParamException('Неправильный токен сброса пароля');
}
parent::__construct($config);
}
示例2: __construct
/**
* Creates a form model given a token.
*
* @param string $token Password reset token.
* @param array $config Name-value pairs that will be used to initialize the object properties.
*
* @throws \yii\base\InvalidParamException If token is empty or not valid.
*/
public function __construct($token, $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidParamException(Yii::t('app', 'Password reset token cannot be blank.'));
}
$this->_user = User::findByPasswordResetToken($token);
if (!$this->_user) {
throw new InvalidParamException(Yii::t('app', 'Wrong password reset token.'));
}
parent::__construct($config);
}
示例3: validateToken
/**
* Validate token
*
* @param string $token
* @return boolean
*/
public function validateToken($token)
{
if (empty($token) || !is_string($token)) {
return false;
}
$this->user = User::findByPasswordResetToken($token);
if (!$this->user) {
return false;
}
return true;
}
示例4: InvalidParamException
function __construct($key, $config = [])
{
if (empty($key) || !is_string($key)) {
throw new InvalidParamException('Ключ не может быть пустым');
}
$this->_user = User::findByPasswordResetToken($key);
if (!$this->_user) {
throw new InvalidParamException('Неверный ключ');
}
parent::__construct($config);
}
示例5: __construct
/**
* Creates a form model given a token.
* @param string $token
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if token is empty or not valid
*/
public function __construct($token, $password, $config = [])
{
if (empty($token) || !is_string($token)) {
throw new InvalidParamException('Ключ для восстановления пароля не найден.');
}
if (empty($password) || !is_string($password)) {
throw new InvalidParamException('Пароль не задан.');
}
$this->_user = User::findByPasswordResetToken($token);
$this->password = $password;
if (!$this->_user) {
throw new InvalidParamException('Неправильный ключ для восстановления пароля.');
}
parent::__construct($config);
}
示例6: actionChangepass
public function actionChangepass()
{
if (!($post = \Yii::$app->getRequest()->getBodyParams())) {
throw new \yii\web\HttpException(400, 'No data was posted');
}
$model = User::findByPasswordResetToken($post['token']);
if (!$model) {
throw new \yii\web\HttpException(422, 'Password reset token is not valid');
}
$password = $post['password'];
$validator = new \yii\validators\StringValidator(['min' => 3, 'max' => 12]);
if (!$validator->validate($password, $error)) {
throw new \yii\web\HttpException(422, $error);
}
$model->setPassword($post['password']);
$model->removePasswordResetToken();
$model->save();
echo $model->username;
exit('ok');
}
示例7: actionReset
public function actionReset($token)
{
$user = User::findByPasswordResetToken($token);
$model = new ResetForm();
if ($model->load(Yii::$app->request->post())) {
if ($user) {
$user->removePasswordResetToken();
$user->password = md5($model->password);
$user->save();
Yii::$app->getSession()->setFlash('success', 'Su password ha sido cambiado con éxito.');
return $this->goHome();
} else {
Yii::$app->getSession()->setFlash('warning', 'El token de seguridad es inválido o ya ha expirado.');
return $this->goHome();
}
}
return $this->render('reset', ['model' => $model]);
}
示例8: actionChangepass
public function actionChangepass()
{
/* echo \Yii::$app->session->get('role');
exit('d');*/
if (!($post = \Yii::$app->getRequest()->getBodyParams())) {
throw new \yii\web\HttpException(400, 'Дані не отримані');
}
$model = User::findByPasswordResetToken($post['token']);
if (!$model) {
throw new \yii\web\HttpException(422, 'Ключ для відновлення паролю не є коректним');
}
$password = $post['password'];
$validator = new \yii\validators\StringValidator(['min' => 3, 'max' => 12, 'tooShort' => 'Пароль повинен містити мінімум {min, number} символи', 'tooLong' => 'Пароль повинен містити не більше {max, number} символів']);
if (!$validator->validate($password, $error)) {
throw new \yii\web\HttpException(422, $error);
}
$model->setPassword($password);
$model->removePasswordResetToken();
$model->save();
echo $model->username;
exit('ok');
}
示例9: actionNewPassword
/**
* установить новый пароль
* @param type $token
* @return type
*/
public function actionNewPassword($token)
{
$user = User::findByPasswordResetToken($token);
if ($user) {
$user->setNewPassword();
Yii::$app->getSession()->setFlash('success', 'Новый пароль выслан на почту');
} else {
Yii::$app->getSession()->setFlash('error', 'Токен не действителен');
}
return $this->goHome();
}
示例10: testFindByPasswordResetToken
public function testFindByPasswordResetToken()
{
$user = $this->tester->grabFixture('user', 'user-1');
expect_that($user = User::findByPasswordResetToken($user->password_reset_token));
expect($user->username)->equals('superuser');
expect_not(User::findByPasswordResetToken(999));
}