當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::hashPassword方法代碼示例

本文整理匯總了PHP中app\modules\user\models\User::hashPassword方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::hashPassword方法的具體用法?PHP User::hashPassword怎麽用?PHP User::hashPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\modules\user\models\User的用法示例。


在下文中一共展示了User::hashPassword方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: changePassword

 /**
  * @return bool
  */
 public function changePassword()
 {
     if (!$this->validate()) {
         return false;
     }
     $user = User::findIdentity(\Yii::$app->user->identity->getId());
     $user->password_hash = User::hashPassword($this->new_password);
     $user->save();
     return true;
 }
開發者ID:vetoni,項目名稱:toko,代碼行數:13,代碼來源:ChangePasswordForm.php

示例2: generatePasswordResetToken

 /**
  * @return bool
  */
 public function generatePasswordResetToken()
 {
     if (!$this->validate()) {
         return false;
     }
     $new_password = \Yii::$app->security->generateRandomString(8);
     /** @var User $user */
     $user = User::findOne(['email' => $this->email]);
     $user->password_reset_token = User::generatePasswordResetToken();
     $user->password_hash = User::hashPassword($new_password);
     $user->status = User::USER_STATUS_INACTIVE;
     $user->save();
     $isSend = \Yii::$app->mailer->compose('user/forgot_password', ['user_name' => $user->name, 'token' => $user->password_reset_token, 'new_password' => $new_password])->setFrom(Settings::value('general', 'shopEmail'))->setTo($this->email)->setSubject(\Yii::t('mail', 'New password activation'))->send();
     if (!$isSend) {
         $this->addError(\Yii::t('mail', 'Oops, can\'t deliver letter to such email address.'));
     }
     return $isSend;
 }
開發者ID:vetoni,項目名稱:toko,代碼行數:21,代碼來源:ForgotPasswordForm.php

示例3: register

 /**
  * @throws \yii\base\Exception
  * @throws \yii\base\InvalidConfigException
  */
 public function register()
 {
     if (!$this->validate()) {
         return false;
     }
     $user = new User();
     $user->email = $this->email;
     $user->name = $this->name;
     $user->country_id = $this->country_id;
     $user->phone = $this->phone;
     $user->address = $this->address;
     $user->password_hash = User::hashPassword($this->password);
     $user->generateAuthKey();
     $user->status = User::USER_STATUS_ACTIVE;
     $user->save();
     return User::login($this->email, true);
 }
開發者ID:vetoni,項目名稱:toko,代碼行數:21,代碼來源:RegisterForm.php


注:本文中的app\modules\user\models\User::hashPassword方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。