Support for other auth types.

This commit is contained in:
Qiang Xue
2014-03-03 10:18:39 -05:00
parent 7b46dc3443
commit 7a04dbaae1
7 changed files with 103 additions and 25 deletions

View File

@ -75,9 +75,9 @@ class User extends ActiveRecord implements IdentityInterface
/**
* @inheritdoc
*/
public static function findIdentityByToken($token)
public static function findIdentityByAccessToken($token)
{
throw new NotSupportedException('"findIdentityByToken" is not implemented.');
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
/**

View File

@ -8,7 +8,7 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
public $username;
public $password;
public $authKey;
public $apiKey;
public $accessToken;
private static $users = [
'100' => [
@ -16,14 +16,14 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
'username' => 'admin',
'password' => 'admin',
'authKey' => 'test100key',
'apiKey' => '100-apikey',
'accessToken' => '100-token',
],
'101' => [
'id' => '101',
'username' => 'demo',
'password' => 'demo',
'authKey' => 'test101key',
'apiKey' => '101-apikey',
'accessToken' => '101-token',
],
];
@ -38,10 +38,10 @@ class User extends \yii\base\Object implements \yii\web\IdentityInterface
/**
* @inheritdoc
*/
public static function findIdentityByToken($token)
public static function findIdentityByAccessToken($token)
{
foreach (self::$users as $user) {
if ($user['apiKey'] === $token) {
if ($user['accessToken'] === $token) {
return new static($user);
}
}