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


PHP User::generateAccessToken方法代码示例

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


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

示例1: register

 /**
  * Signs user up.
  * @return User|null the saved model or null if saving fails
  * @internal param string $avatar
  */
 public function register()
 {
     if ($this->validate()) {
         $user = new User(['scenario' => 'register']);
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setHashPassword($this->password);
         $user->generateAuthKey();
         $user->generateAccessToken();
         $user->password = md5($this->password);
         if ($this->saveAvatar(UploadedFile::getInstance($this, 'avatar'))) {
             $user->avatar = $this->avatar;
         } else {
             Yii::$app->session->setFlash('alert', '注册失败');
             Yii::$app->session->setFlash('alert-type', 'alert-danger');
             return false;
         }
         if ($user->save()) {
             return $user;
         } else {
             Yii::$app->session->setFlash('alert', '注册失败');
             Yii::$app->session->setFlash('alert-type', 'alert-danger');
             return false;
         }
     }
     return null;
 }
开发者ID:kangqf,项目名称:kblog_with_yii2,代码行数:32,代码来源:RegisterForm.php

示例2: signup

 /**
  * Signs user up.
  *
  * @return User|false the saved model or false if saving fails
  */
 public function signup($runValidation = true)
 {
     if ($runValidation && !$this->validate()) {
         return false;
     }
     $user = new User();
     $user->mobile = $this->_session['mobileSignup'];
     $user->setPassword($this->_session['mobileSignupPassword']);
     $user->generateAuthKey();
     $user->generateAccessToken();
     $transaction = Yii::$app->db->beginTransaction();
     try {
         if (!$user->save(false)) {
             throw new \Exception();
         }
         $userAccount = new UserAccount();
         $userAccount->id = $user->id;
         $userAccount->password_hash = null;
         if (!$userAccount->save(false)) {
             throw new \Exception();
         }
         $transaction->commit();
         return $user;
     } catch (\Exception $e) {
         $transaction->rollBack();
         return false;
     }
 }
开发者ID:daixianceng,项目名称:xiaoego.com,代码行数:33,代码来源:SignupMobileVerifyForm.php

示例3: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         $user->generateAccessToken();
         if ($user->save()) {
             return $user;
         }
     }
     return null;
 }
开发者ID:kuznetsov0209,项目名称:mercdev-soccer-server,代码行数:20,代码来源:SignupForm.php

示例4: save

 public function save($runValidation = true, $attributeNames = null)
 {
     if ($this->validate()) {
         $user = new User();
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->pass_agreement = $this->pass_agreement;
         $user->generateAccessToken();
         if ($user->save()) {
             return $user;
         } else {
             if ($user->hasErrors()) {
                 foreach ($user->getErrors() as $error) {
                     $this->addError('email', $error[0]);
                 }
             } else {
                 throw new \Exception('create user failed, please contact the supporter');
             }
         }
     }
     return false;
 }
开发者ID:dawei101,项目名称:plants,代码行数:22,代码来源:SignupForm.php

示例5: createUser

 /**
  * 建立用户记录
  * @return bool|User
  */
 public function createUser()
 {
     $user = new User(['scenario' => 'register']);
     $user->username = $this->username;
     $user->email = $this->email;
     $user->avatar = $this->avatar;
     $user->status = 9;
     $user->generateAuthKey();
     $user->generateAccessToken();
     if ($user->save()) {
         return $user;
     } else {
         return false;
     }
 }
开发者ID:kangqf,项目名称:kblog_with_yii2,代码行数:19,代码来源:OpenUser.php


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