diff --git a/BTCPayServer/Authentication/TokenRepository.cs b/BTCPayServer/Authentication/TokenRepository.cs index e4ad7d9fc..d2a74d638 100644 --- a/BTCPayServer/Authentication/TokenRepository.cs +++ b/BTCPayServer/Authentication/TokenRepository.cs @@ -167,6 +167,8 @@ namespace BTCPayServer.Authentication private PairingCodeEntity CreatePairingCodeEntity(PairingCodeData data) { + if(data == null) + return null; return new PairingCodeEntity() { Facade = data.Facade, diff --git a/BTCPayServer/Controllers/AccessTokenController.cs b/BTCPayServer/Controllers/AccessTokenController.cs index b72c90a4c..9d4d588b0 100644 --- a/BTCPayServer/Controllers/AccessTokenController.cs +++ b/BTCPayServer/Controllers/AccessTokenController.cs @@ -56,6 +56,8 @@ namespace BTCPayServer.Controllers throw new BitpayHttpException(400, "'id' property is required, alternatively, use BitId"); pairingEntity = await _TokenRepository.GetPairingAsync(request.PairingCode); + if(pairingEntity == null) + throw new BitpayHttpException(404, "The specified pairingCode is not found"); pairingEntity.SIN = sin; if(string.IsNullOrEmpty(pairingEntity.Label) && !string.IsNullOrEmpty(request.Label))