mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Изменён алгоритм авторизации на использование jwt токенов
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
namespace common\models;
|
||||
|
||||
use common\components\UserPass;
|
||||
use damirka\JWT\UserTrait;
|
||||
use Yii;
|
||||
use yii\base\InvalidConfigException;
|
||||
use yii\base\NotSupportedException;
|
||||
@@ -34,6 +35,7 @@ use yii\web\IdentityInterface;
|
||||
* @mixin TimestampBehavior
|
||||
*/
|
||||
class Account extends ActiveRecord implements IdentityInterface {
|
||||
use UserTrait;
|
||||
|
||||
const STATUS_DELETED = -10;
|
||||
const STATUS_REGISTERED = 0;
|
||||
@@ -64,13 +66,6 @@ class Account extends ActiveRecord implements IdentityInterface {
|
||||
return static::findOne(['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function findIdentityByAccessToken($token, $type = null) {
|
||||
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @return static|null
|
||||
@@ -247,4 +242,22 @@ class Account extends ActiveRecord implements IdentityInterface {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected static function getSecretKey() {
|
||||
return Yii::$app->params['jwtSecret'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for "header" array that's used for generation of JWT
|
||||
* @return array JWT Header Token param, see http://jwt.io/ for details
|
||||
*/
|
||||
protected static function getHeaderToken() {
|
||||
return [
|
||||
'iss' => Yii::$app->request->hostInfo,
|
||||
'aud' => Yii::$app->request->hostInfo,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user