Skip to content

Commit

Permalink
Merge branch 'master' into 1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dersonsena committed Nov 10, 2021
2 parents 9cdcf79 + 16861d4 commit 5cc944f
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/JWTTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use stdClass;
use yii\db\ActiveRecord;
use yii\helpers\BaseStringHelper;
use yii\web\UnauthorizedHttpException;

final class JWTTools
{
Expand Down Expand Up @@ -111,10 +112,6 @@ public function withModel(ActiveRecord $model, array $attributes = []): self
return $this;
}

/**
* @return string
* @throws Exception
*/
public function getJWT(): string
{
try {
Expand All @@ -125,18 +122,16 @@ public function getJWT(): string
$this->payload->get('sub')
);
} catch (ExpiredException $e) {
throw new UnauthorizedHttpException('Authentication token is expired.');
}
}

/**
* @param string $token
* @return stdClass
*/
public function decodeToken(string $token): stdClass
{
try {
return JWT::decode($token, $this->secretKey, [$this->algorithm]);
} catch (ExpiredException $e) {
throw new UnauthorizedHttpException('Authentication token is expired.');
}
}

Expand Down

0 comments on commit 5cc944f

Please sign in to comment.