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


PHP User::set方法代碼示例

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


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

示例1: persona

 public static function persona()
 {
     $c = curl_init();
     $audience = 'https://' . \Config::$domain . ':443';
     curl_setopt_array($c, array(CURLOPT_SSL_VERIFYPEER => TRUE, CURLOPT_URL => 'https://verifier.login.persona.org/verify', CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_POST => 2, CURLOPT_POSTFIELDS => 'assertion=' . urlencode($_POST['assertion']) . '&audience=' . urlencode($audience)));
     $result = curl_exec($c);
     if ($result === FALSE) {
         http_response_code(500) && exit('Could not connect to Person :/');
     }
     curl_close($c);
     $object = json_decode($result);
     if ($object->audience !== $audience) {
         http_response_code(500) && exit('Wrong audience?!');
     }
     if ($object->status !== 'okay') {
         http_response_code(500) && exit('Persona status is not okay :/');
     }
     $_SESSION['persona'] = $object->email;
     $_SESSION['range'] = \Config::$defaultRange;
     $sGetUser = \Core\DB::$db->prepare('SELECT * FROM user WHERE email = :email');
     $sGetUser->execute([':email' => $object->email]);
     $rGetUser = $sGetUser->fetchAll(\PDO::FETCH_OBJ);
     $sGetUser->closeCursor();
     if (count($rGetUser) === 1) {
         $user = current($rGetUser);
         $_SESSION['user_id'] = $user->user_id;
     } else {
         $user = new \stdClass();
         $user->email = $object->email;
         $_SESSION['user_id'] = \Models\User::set(NULL, $user);
     }
 }
開發者ID:rlaskey,項目名稱:dm-track,代碼行數:32,代碼來源:auth.php

示例2: seedUser

 public function seedUser()
 {
     $user = new UserModel();
     $user->set('username', $this->faker->userName($this->gender));
     //$user->set('email', $this->faker->freeEmail);
     $user->set('password', UserModel::hashPassword("Scr0tums"));
     $user->set('gender', $this->gender);
     $user->set('created_ts', date("Y-m-d H:i:s"));
     $user->set('fake', 1);
     $user->set('secret_key', Keys::createSecret($user));
     $user->set('public_key', Keys::createPublic($user));
     $user->save();
     return $user;
 }
開發者ID:lenlyle1,項目名稱:lightupdating,代碼行數:14,代碼來源:User.php


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