Enabled OAuth/OAuth2 logins

This commit is contained in:
Deon George
2013-05-27 22:10:41 +10:00
parent 7dd64e68bf
commit d4a2ace403
82 changed files with 3052 additions and 154 deletions

View File

@@ -21,26 +21,12 @@ class Controller_Oauth extends Controller_TemplateDefault {
if (! $oo->loaded() OR ! $oo->status)
HTTP::redirect('login');
$auth = NULL;
$auth = Auth::instance($oo);
if ($oo->name == 'facebook') {
// User Denied a Facebook authorisation, so we'll go back to login
// We wouldnt normally get here, since we are doing JS authentication
if ($this->request->query('error') AND $this->request->query('error_reason') == 'user_denied')
HTTP::redirect('login');
if (! $auth->logged_in())
HTTP::redirect($auth->login_url());
$auth = Auth::instance($oo);
// If we are not logged in, do the facebook stuff.
// We wouldnt normally get here, since we are doing JS authentication
if (! $auth->logged_in())
HTTP::redirect($auth->login_url());
// Here we must be logged in to Facebook
// @todo Only use verified accounts - is this applicable?
$aoo = $oo->account_oauth->where('userid','=',$auth->user_id())->find();
}
$aoo = $oo->account_oauth->where('userid','=',$auth->user_id())->find();
// If we have an ID, we have been linked, redirect to login
if ($aoo->loaded() AND $auth->login($aoo->account,$auth->user_id(),$auth))