(string)$token->claims()->get('uid'), 'role' =>(string)$token->claims()->get('role'), 'priceType' => (int)$token->claims()->get('priceType'), ]); } /** * Finds user by username * * @param string $username * @return static|null */ public static function findByUsername($username) { return self::findIdentity((string) $username); } /** * {@inheritdoc} */ public function getId() { return $this->id; } public function getRole() { return $this->role; } /** * {@inheritdoc} */ public function getAuthKey() { return null; } /** * {@inheritdoc} */ public function validateAuthKey($authKey) { return false; } /** * Validates password * * @param string $password password to validate * @return bool if password provided is valid for current user */ public function validatePassword($password) { return $this->password === hash('sha512',$password); } public function getRateLimit($request, $action) { return [1000, 1]; // $rateLimit requests per second } public function loadAllowance($request, $action) { return [1000, time()]; } public function saveAllowance($request, $action, $allowance, $timestamp) { } public static function getPriceTypeId() { return isset(Yii::$app->user) ? Yii::$app->user->identity->priceType : 1; } public static function getAuthMemberId() { return isset(Yii::$app->user) ? Yii::$app->user->identity->id : 0; } }