I installed HybridAuth 2.8 using composer and I'm trying to use it with CodeIgniter 3.
I created a library which is extending Hybrid_Auth.
class MY_HybridAuth extends Hybrid_Auth {
function __construct($config = []) {
$this->_CI =& get_instance();
$this->_CI->load->helper('url');
$config = $this->_CI->config->item('hybridauth');
$config['base_url'] = base_url() . $config['base_url'];
parent::__construct($config);
}
}
My controller :
public function social($provider) {
$provider = ucfirst($provider);
log_message('debug', "controllers.Auth.social($provider)");
// TODO Handle missing parameter properly
if (!isset($provider)) redirect('login', 'location');
try {
if ($this->HybridAuth->is_provider_enabled($provider)) {
$service = $this->HybridAuth->authenticate($provider);
var_dump($service->getUserProfile());
}
} catch (Exception $e) {
var_dump($e);
}
}
public function endpoint() {
if (isset($_REQUEST['hauth_start']) || isset($_REQUEST['hauth_done'])) {
Hybrid_Endpoint::process();
}
}
My problem is :
When the user is redirected to /login/social/endpoint?auth.start...
, HybridAuth appends the current url to the new one (localhost/login/localhost/login/social/endpoint?auth.start...
).
HybridAuth is using header("Location: $url")
to redirect the user. I setted my base_url
to localhost
. My HybridAuth endpoint is : base_url() . /login/social/endpoint
, which is handled by the endpoint
method in above controller.
May someone help ?