當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。