Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
fix some bugs in code
Browse files Browse the repository at this point in the history
  • Loading branch information
skie committed Jan 12, 2012
1 parent 598e8cd commit 8e448a5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Lib/OAuth2StorageCake.php
Expand Up @@ -177,12 +177,15 @@ public function checkRestrictedGrantType($client_id, $grant_type) {
*/ */
protected function setToken($token, $client_id, $user_id, $expires, $scope, $isRefresh = TRUE) { protected function setToken($token, $client_id, $user_id, $expires, $scope, $isRefresh = TRUE) {
$model = 'Token'; $model = 'Token';
if ($isRefresh == true) { if ($isRefresh) {
$model = 'RefreshToken'; $model = 'RefreshToken';
$refresh_token = $token;
} else {
$oauth_token = $token;
} }


$this->{$model}->save(array( $this->{$model}->save(array(
$this->{$model}->alias => compact('token', 'client_id', 'user_id', 'expires', $this->{$model}->alias => compact('refresh_token', 'oauth_token', 'client_id', 'user_id', 'expires',
'scope'))); 'scope')));
} }


Expand All @@ -204,7 +207,7 @@ protected function getToken($token, $isRefresh = true) {
if (empty($result)) { if (empty($result)) {
return null; return null;
} }
return $result[$this->AuthCode->alias]; return $result[$this->{$model}->alias];
} }


/** /**
Expand Down
7 changes: 7 additions & 0 deletions Model/Oauth2AccessToken.php
Expand Up @@ -9,4 +9,11 @@ class Oauth2AccessToken extends Oauth2AppModel {
*/ */
public $name = 'Oauth2AccessToken'; public $name = 'Oauth2AccessToken';


/**
* Primary key
*
* @var string
*/
public $primaryKey = 'oauth_token';

} }
8 changes: 8 additions & 0 deletions Model/Oauth2AuthCode.php
Expand Up @@ -9,4 +9,12 @@ class Oauth2AuthCode extends Oauth2AppModel {
*/ */
public $name = 'Oauth2AuthCode'; public $name = 'Oauth2AuthCode';


/**
* Primary key
*
* @var string
*/
public $primaryKey = 'code';


} }
6 changes: 6 additions & 0 deletions Model/Oauth2RefreshToken.php
Expand Up @@ -9,4 +9,10 @@ class Oauth2RefreshToken extends Oauth2AppModel {
*/ */
public $name = 'Oauth2RefreshToken'; public $name = 'Oauth2RefreshToken';


/**
* Primary key
*
* @var string
*/
public $primaryKey = 'refresh_token';
} }

0 comments on commit 8e448a5

Please sign in to comment.