本文整理匯總了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);
}
}
示例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;
}