Fix read image URLs with token param (#5027)

This commit is contained in:
Yuriy Bakhtin 2021-04-20 15:44:21 +03:00 committed by GitHub
parent 4558d2ac91
commit 01d07e2936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -248,8 +248,8 @@ class DownloadAction extends Action
} catch (\Exception $ex) {
Yii::warning('Could not decode provided JWT token. ' . $ex->getMessage());
}
if (!empty($decoded['sub']) && !empty($decoded['aud']) && $decoded['aud'] == $file->id) {
return User::findOne(['id' => $decoded['sub']]);
if (!empty($decoded->sub) && !empty($decoded->aud) && $decoded->aud == $file->id) {
return User::findOne(['id' => $decoded->sub]);
}
return null;
@ -266,7 +266,7 @@ class DownloadAction extends Action
{
$token = [
'iss' => 'dld-token-v1',
'sub' => Yii::$app->user->id,
'sub' => $user->id,
'aud' => $file->id
];
return JWT::encode($token, static::getDownloadTokenKey());