From d3a9d963a4e1728fc1ec54a9419add9c6e94ff61 Mon Sep 17 00:00:00 2001 From: hishamco Date: Sun, 4 Sep 2022 21:01:29 +0300 Subject: [PATCH 1/2] Avoid NRE in ImportRemoteInstanceController.import() --- .../Controllers/ImportRemoteInstanceController.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/Controllers/ImportRemoteInstanceController.cs b/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/Controllers/ImportRemoteInstanceController.cs index 49050550a82..9da850612b6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/Controllers/ImportRemoteInstanceController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/Controllers/ImportRemoteInstanceController.cs @@ -43,9 +43,14 @@ public async Task Import(ImportViewModel model) var remoteClient = remoteClientList.RemoteClients.FirstOrDefault(x => x.ClientName == model.ClientName); + if (remoteClient == null) + { + return StatusCode((int)HttpStatusCode.BadRequest, "The Api Key was not recognized"); + } + var apiKey = Encoding.UTF8.GetString(_dataProtector.Unprotect(remoteClient.ProtectedApiKey)); - if (remoteClient == null || model.ApiKey != apiKey || model.ClientName != remoteClient.ClientName) + if (model.ApiKey != apiKey || model.ClientName != remoteClient.ClientName) { return StatusCode((int)HttpStatusCode.BadRequest, "The Api Key was not recognized"); } From 5e17276e39f228379117fc679b898e0bdd71327f Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Tue, 6 Sep 2022 00:04:25 +0300 Subject: [PATCH 2/2] Update status code message Co-authored-by: Jasmin Savard --- .../Controllers/ImportRemoteInstanceController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/Controllers/ImportRemoteInstanceController.cs b/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/Controllers/ImportRemoteInstanceController.cs index 9da850612b6..c80bccd2538 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/Controllers/ImportRemoteInstanceController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment.Remote/Controllers/ImportRemoteInstanceController.cs @@ -45,7 +45,7 @@ public async Task Import(ImportViewModel model) if (remoteClient == null) { - return StatusCode((int)HttpStatusCode.BadRequest, "The Api Key was not recognized"); + return StatusCode((int)HttpStatusCode.BadRequest, "The remote client was not provided"); } var apiKey = Encoding.UTF8.GetString(_dataProtector.Unprotect(remoteClient.ProtectedApiKey));