|
|
EasyOpenID Library in code igniter - PHP
|
Views : 335
|
|
Tagged in : PHP
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
<?php
class Yours extends Controller {
function Yours()
{
parent::Controller();
// load the OpenID library
$this->load->library('openid');
}
function index()
{
// get the link data
$data['openid_links'] = $this->openid->build_auth(
'yours/try_auth', array('openid', 'google', 'yahoo'), 'yours/load_icon');
// load the sign in page
$this->load->view('signin', $data);
}
function try_auth()
{
// figure out which provider we're loading
$which = $this->uri->segment(3);
switch ($which)
{
// handle standard OpenID
case 'openid':
if (array_key_exists('openid', $_POST))
{
$result = $this->openid->try_auth($_POST['openid'], 'yours/finish_auth');
}
else
{
$data['message'] = 'No Provider Given';
}
break;
// handle Google Accounts
case 'google':
$result = $this->openid->try_auth_google('yours/finish_auth');
break;
// handle Yahoo!
case 'yahoo':
$result = $this->openid->try_auth_yahoo('yours/finish_auth');
break;
// handle errors
default:
$data['message'] = 'Invalid Provider';
break;
}
// handle errors
if (isset($result) && is_int($result))
{
$data['message'] = $this->openid->last_error();
}
$this->load->view('signin', $data);
}
function finish_auth()
{
// finish authentication
$result = $this->openid->finish_auth();
// check for errors
if (is_int($result))
{
$data['error'] = $this->openid->last_error();
}
else
{
$data['user_data'] = $result;
}
// load the next page
$this->load->view('next/page', $data);
}
// create the icon loader
function load_icon()
{
$this->openid->icon_loader();
}
}
/* End of file * |
|
By gowtham, On - 2010-09-17 |
|
|
|