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