本文整理汇总了PHP中UserHelper::createAccount方法的典型用法代码示例。如果您正苦于以下问题:PHP UserHelper::createAccount方法的具体用法?PHP UserHelper::createAccount怎么用?PHP UserHelper::createAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserHelper
的用法示例。
在下文中一共展示了UserHelper::createAccount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSocial
/**
* Performs social login.
*
* @param string $provider The name of the social network.
*/
public function actionSocial($provider)
{
if (Yii::app()->hasModule('social') && Yii::app()->hasModule('registration')) {
/* social and registration modules are loaded */
Yii::import('application.modules.social.models.*');
Yii::import('application.modules.social.components.*');
try {
$provider_params = array('redirect_uri' => 'http://' . $_SERVER['HTTP_HOST'] . Yii::app()->request->requestUri);
$p = ProviderManager::getInstance($provider, $provider_params);
if (isset($p)) {
$result = $p->isAuthorized();
$user = null;
if ($result['success']) {
// app authorized
if (!isset(Yii::app()->session['registration_user_id'])) {
if ($result['registration_required']) {
$user = UserHelper::createAccount($result['user_data']['social_email'], null, null, true, false, false);
$p->setSession($result['user_data']);
$p->storeOauthData($user->id, $result['user_data']);
} else {
$user = User::model()->findByPk($result['user_id']);
$identity = new SocialUserIdentity($result['user_id'], $result['user_data']);
$identity->authenticate();
$p->storeOauthData($result['user_id'], $result['user_data']);
}
} else {
$user = User::model()->findByPk(Yii::app()->session['registration_user_id']);
if (isset($user)) {
$p->setSession($result['user_data']);
$p->storeOauthData($user->id, $result['user_data']);
}
}
$p->pullData($result['user_data']['social_oauth_id'], $result['user_data']['social_oauth_token'], $user);
if (isset(Yii::app()->session['registration_user_id'])) {
$this->redirect(Yii::app()->createUrl('registration'));
} else {
if ($result['registration_required']) {
$this->redirect(Yii::app()->createUrl('registration'));
} else {
$this->redirect(Yii::app()->baseUrl);
}
}
} else {
// app not authorized
$this->redirect($result['url']);
}
}
} catch (Exception $ex) {
$this->redirect(Yii::app()->createUrl('users'));
}
} else {
/* modules are not loaded */
$this->redirect(Yii::app()->createUrl('users'));
}
}
示例2: performBasicRegistration
/**
*
* @param unknown $model
* @return boolean
*/
protected function performBasicRegistration($model)
{
$output = false;
if (isset($model)) {
$email = isset($model->email) ? $model->email : null;
if (isset($email)) {
if (isset(Yii::app()->session['social_email'])) {
$this->_user = UserHelper::createAccount($email, $model->nickname, $model->password, true, true, true, Yii::app()->session['social_email']);
} else {
$this->_user = UserHelper::createAccount($email, $model->nickname, $model->password);
}
Yii::app()->session['registration_user_id'] = $this->_user->id;
Yii::app()->session['registration_user_email'] = $email;
$output = isset($this->_user->id);
}
}
return $output;
}