diff --git a/Pilz.Net/Api/ApiServer.cs b/Pilz.Net/Api/ApiServer.cs index 0bd7dfe..76b568e 100644 --- a/Pilz.Net/Api/ApiServer.cs +++ b/Pilz.Net/Api/ApiServer.cs @@ -481,10 +481,9 @@ public class ApiServer : IApiServer // Check authentication Log.Debug("Check authentication"); var isAuthenticated = false; - if (!string.IsNullOrWhiteSpace(authKey) && DecodeAuthKey(authKey) is string authKeyDecoded) - isAuthenticated = CheckAuthentication(authKeyDecoded, handler.Handler, context); - else + if (string.IsNullOrWhiteSpace(authKey) || DecodeAuthKey(authKey) is not string authKeyDecoded) authKeyDecoded = null!; + isAuthenticated = CheckAuthentication(authKeyDecoded, handler.Handler, context); if (handler.Attribute.RequiesAuth && !isAuthenticated) return new(ApiResult.Unauthorized(), null);