当前位置: 首页>>代码示例>>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;未经允许,请勿转载。