本文整理汇总了PHP中Social::include_vendor方法的典型用法代码示例。如果您正苦于以下问题:PHP Social::include_vendor方法的具体用法?PHP Social::include_vendor怎么用?PHP Social::include_vendor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Social
的用法示例。
在下文中一共展示了Social::include_vendor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_login
public function action_login()
{
//if user loged in redirect home
if (Auth::instance()->logged_in()) {
Auth::instance()->login_redirect();
}
Social::include_vendor();
$user = FALSE;
$config = Social::get();
if ($this->request->query('hauth_start') or $this->request->query('hauth_done')) {
try {
Hybrid_Endpoint::process($this->request->query());
} catch (Exception $e) {
Alert::set(Alert::ERROR, $e->getMessage());
$this->redirect(Route::url('default'));
}
} else {
$provider_name = $this->request->param('id');
try {
// initialize Hybrid_Auth with a given file
$hybridauth = new Hybrid_Auth($config);
// try to authenticate with the selected provider
if ($provider_name == 'openid') {
$params = array('openid_identifier' => 'https://openid.stackexchange.com/');
} else {
$params = NULL;
}
$adapter = $hybridauth->authenticate($provider_name, $params);
if ($hybridauth->isConnectedWith($provider_name)) {
//var_dump($adapter->getUserProfile());
$user_profile = $adapter->getUserProfile();
}
} catch (Exception $e) {
Alert::set(Alert::ERROR, __('Error: please try again!') . " " . $e->getMessage());
$this->redirect(Route::url('default'));
}
//try to login the user with same provider and identifier
$user = Auth::instance()->social_login($provider_name, $user_profile->identifier);
//we couldnt login create account
if ($user == FALSE) {
$email = $user_profile->emailVerified != NULL ? $user_profile->emailVerified : $user_profile->email;
$name = $user_profile->firstName != NULL ? $user_profile->firstName . ' ' . $user_profile->lastName : $user_profile->displayName;
//if not email provided
if (!Valid::email($email, TRUE)) {
Alert::set(Alert::INFO, __('We need your email address to complete'));
//redirect him to select the email to register
$this->redirect(Route::url('default', array('controller' => 'social', 'action' => 'register', 'id' => $provider_name)) . '?uid=' . $user_profile->identifier . '&name=' . $name);
} else {
//register the user in DB
Model_User::create_social($email, $name, $provider_name, $user_profile->identifier);
//log him in
Auth::instance()->social_login($provider_name, $user_profile->identifier);
}
} else {
Alert::set(Alert::SUCCESS, __('Welcome!'));
}
$this->redirect(Session::instance()->get_once('auth_redirect', Route::url('default')));
}
}