Fixes ACCOUNTS-2. Catch decryption exception for OAuth2 flow

This commit is contained in:
ErickSkrauch
2020-08-23 00:23:36 +03:00
parent 503880615a
commit 2a4f29801d
3 changed files with 21 additions and 6 deletions

View File

@@ -3,6 +3,9 @@ declare(strict_types=1);
namespace api\components\OAuth2;
use LogicException;
use RangeException;
use SodiumException;
use Yii;
/**
@@ -20,7 +23,11 @@ trait CryptTrait {
}
protected function decrypt($encryptedData): string {
return Yii::$app->tokens->decryptValue($encryptedData);
try {
return Yii::$app->tokens->decryptValue($encryptedData);
} catch (SodiumException | RangeException $e) {
throw new LogicException($e->getMessage(), 0, $e);
}
}
}