Permalink
Browse files

fix some bugs in code

  • Loading branch information...
skie committed Jan 12, 2012
1 parent 598e8cd commit 8e448a5f3781a370d43263f54cd9f1023c8fb297
Showing with 27 additions and 3 deletions.
  1. +6 −3 Lib/OAuth2StorageCake.php
  2. +7 −0 Model/Oauth2AccessToken.php
  3. +8 −0 Model/Oauth2AuthCode.php
  4. +6 −0 Model/Oauth2RefreshToken.php
@@ -177,12 +177,15 @@ public function checkRestrictedGrantType($client_id, $grant_type) {
*/
protected function setToken($token, $client_id, $user_id, $expires, $scope, $isRefresh = TRUE) {
$model = 'Token';
- if ($isRefresh == true) {
+ if ($isRefresh) {
$model = 'RefreshToken';
+ $refresh_token = $token;
+ } else {
+ $oauth_token = $token;
}
$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')));
}
@@ -204,7 +207,7 @@ protected function getToken($token, $isRefresh = true) {
if (empty($result)) {
return null;
}
- return $result[$this->AuthCode->alias];
+ return $result[$this->{$model}->alias];
}
/**
@@ -9,4 +9,11 @@ class Oauth2AccessToken extends Oauth2AppModel {
*/
public $name = 'Oauth2AccessToken';
+/**
+ * Primary key
+ *
+ * @var string
+ */
+ public $primaryKey = 'oauth_token';
+
}
View
@@ -9,4 +9,12 @@ class Oauth2AuthCode extends Oauth2AppModel {
*/
public $name = 'Oauth2AuthCode';
+/**
+ * Primary key
+ *
+ * @var string
+ */
+ public $primaryKey = 'code';
+
+
}
@@ -9,4 +9,10 @@ class Oauth2RefreshToken extends Oauth2AppModel {
*/
public $name = 'Oauth2RefreshToken';
+/**
+ * Primary key
+ *
+ * @var string
+ */
+ public $primaryKey = 'refresh_token';
}

0 comments on commit 8e448a5

Please sign in to comment.