This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/oauth/classes/Auth/ORM/External.php
2013-10-10 13:56:13 +11:00

51 lines
1.2 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class extends Auth_ORM to enable external authentication
*
* @package OAuth
* @category Classes
* @author Deon George
* @copyright (c) 2009-2013 Deon George
* @license http://dev.leenooks.net/license.html
*/
abstract class Auth_ORM_External extends Auth_ORM {
// Our Authentication Object
protected $ao;
// Our OAuth Model Object
protected $oo;
public function __construct(Model_Oauth $oo) {
parent::__construct((array)Kohana::$config->load('auth'));
$this->oo = $oo;
}
protected function _login($user,$password,$remember) {
$this->complete_login($user);
if ($remember) {
$aoo = $this->oo->account_oauth->where('account_id','=',$user->id)->find();
// Record our user in the DB
$aoo->account_id = $user->id;
$aoo->oauth_id = $this->oo->id;
$aoo->userid = $remember->user_id();
if ($user instanceof Auth_ORM_External_OAuth2 OR $user instanceof Auth_ORM_External_OAuth)
$aoo->oauth_data = array(
'token'=>$remember->token,
);
elseif ($user instanceof Auth_ORM_External)
$aoo->oauth_data = array(
'token'=>$remember->ao->getAccessToken(),
);
return $aoo->save();
}
return TRUE;
}
}
?>