当前位置: 首页>>代码示例>>PHP>>正文


PHP User::validatePassword方法代码示例

本文整理汇总了PHP中app\models\User::validatePassword方法的典型用法代码示例。如果您正苦于以下问题:PHP User::validatePassword方法的具体用法?PHP User::validatePassword怎么用?PHP User::validatePassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\User的用法示例。


在下文中一共展示了User::validatePassword方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validatePassword

 /**
  * @param string $attribute
  * @param array $params
  */
 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors()) {
         if (!$this->_user->validatePassword($this->{$attribute})) {
             $this->addError($attribute, Yii::t('app', 'ERROR_WRONG_CURRENT_PASSWORD'));
         }
     }
 }
开发者ID:aekkapun,项目名称:seokeys,代码行数:12,代码来源:PasswordChangeForm.php

示例2: validatePassword

 /**
  * @param string $attribute
  * @param array $params
  */
 public function validatePassword($attribute, $params)
 {
     if (!$this->hasErrors()) {
         if (!$this->_user->validatePassword($this->{$attribute})) {
             $this->addError($attribute, 'Неверный адрес или пароль');
         }
     }
 }
开发者ID:sAnbl4,项目名称:getlooky-test,代码行数:12,代码来源:PasswordChangeForm.php

示例3: testUserPasswordValidation

 public function testUserPasswordValidation()
 {
     $user = new User(['username' => 'test', 'email' => 'test@example.com', 'password' => 'secretpassword']);
     $this->assertTrue($user->save());
     $this->assertNotNull($user->auth_key);
     $this->specify('i can validate passwords', function () use($user) {
         expect('invalid password is not verified', $user->validatePassword('wrongpw'))->false();
         expect('valid password is verified', $user->validatePassword('secretpassword'))->true();
     });
 }
开发者ID:maxwelldu,项目名称:yii2-dockerized,代码行数:10,代码来源:UserTest.php

示例4: changePassword

 /**
  * Signs user up
  *
  * @param User $user
  * @return User|null the saved model or null if saving fails
  */
 public function changePassword($user)
 {
     if ($this->validate()) {
         if ($user->validatePassword($this->currentPassword)) {
             $user->setPassword($this->password);
             $user->generateAuthKey();
             if ($user->save()) {
                 return $user;
             }
         } else {
             $this->addError('currentPassword', 'Current password is incorrect');
         }
     }
     return null;
 }
开发者ID:martinmayer,项目名称:notejam,代码行数:21,代码来源:ChangePassword.php

示例5: Auth

 /**
  * Finds user by username and password
  *
  * @param string $username
  * @param string $password
  * @return static|null
  */
 public function Auth($username, $password)
 {
     // username, password are mandatory fields
     if (empty($username) || empty($password)) {
         return null;
     }
     // Yii::$app->getSecurity()->generatePasswordHash($this->password);
     // get user using requested username
     $user = User::findOne(['username' => $username]);
     if (empty($user)) {
         return null;
     }
     // validate password
     $this->password = $user->password;
     $isPass = User::validatePassword($password);
     // if password validation fails
     if (!$isPass) {
         return null;
     }
     // if user validates (both user_email, user_password are valid)
     return $user;
 }
开发者ID:shii,项目名称:yii-app,代码行数:29,代码来源:AirportController.php

示例6: testValidatePassword

 public function testValidatePassword()
 {
     $user = new User();
     $user->load($this->user['user1'], false);
     $this->assertTrue($user->validatePassword("yiibook"));
 }
开发者ID:NikDevPHP,项目名称:yii2-blog,代码行数:6,代码来源:UserTest.php

示例7: userPasswordValidator

 public function userPasswordValidator($attribute, $params)
 {
     if (!$this->_user->validatePassword($this->{$attribute})) {
         $this->addError($attribute, 'Please enter correct old password.');
     }
 }
开发者ID:shahid80,项目名称:EWay,代码行数:6,代码来源:ChangePasswordForm.php

示例8: testUserValidatePassword

 public function testUserValidatePassword()
 {
     $user = new User();
     expect_not($user->validatePassword(''));
     $user = User::findByEmail('user-2@example.com');
     expect_that($user->validatePassword('123123'));
     expect_not($user->validatePassword('test_password'));
 }
开发者ID:rkit,项目名称:bootstrap-yii2,代码行数:8,代码来源:UserTest.php


注:本文中的app\models\User::validatePassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。