Skip to content

Commit dd017ee

Browse files
committed
load token before using it directly
1 parent d032130 commit dd017ee

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/components/TokenManager.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public function getRoles(): array
5050
return [];
5151
}
5252

53+
/**
54+
* @inheritdoc
55+
* @throws LoadTokenException
56+
*/
5357
public function getClaim(string $name, $default = null): mixed
5458
{
5559
if ($this->isStorageEnabled() && $this->loadTokenFromStorage()) {
@@ -58,6 +62,18 @@ public function getClaim(string $name, $default = null): mixed
5862
return $default;
5963
}
6064

65+
/**
66+
* @inheritdoc
67+
* @throws LoadTokenException
68+
*/
69+
public function getToken(): UnencryptedToken
70+
{
71+
if ($this->isStorageEnabled() && !$this->loadTokenFromStorage()) {
72+
throw new LoadTokenException('Error while loading token data');
73+
}
74+
return parent::getToken();
75+
}
76+
6177
/**
6278
* Persist set token in (session) storage
6379
*
@@ -98,4 +114,4 @@ public function isStorageEnabled(): bool
98114
{
99115
return Yii::$app->getUser()->enableSession;
100116
}
101-
}
117+
}

0 commit comments

Comments
 (0)