diff --git a/Pilz.Net/Api/ApiAuthCheckEventArgs.cs b/Pilz.Net/Api/ApiAuthCheckEventArgs.cs index 125baeb..53bf914 100644 --- a/Pilz.Net/Api/ApiAuthCheckEventArgs.cs +++ b/Pilz.Net/Api/ApiAuthCheckEventArgs.cs @@ -1,9 +1,11 @@ namespace Pilz.Net.Api; -public class ApiAuthCheckEventArgs(string authKey) : EventArgs +public class ApiAuthCheckEventArgs(string authKey, Delegate? handler) : EventArgs { private bool hasDenyed; + public Delegate? Handler { get; } + public string AuthKey { get; } = authKey; public bool Valid { get; set; } diff --git a/Pilz.Net/Api/ApiServer.cs b/Pilz.Net/Api/ApiServer.cs index ce30082..8888099 100644 --- a/Pilz.Net/Api/ApiServer.cs +++ b/Pilz.Net/Api/ApiServer.cs @@ -205,7 +205,7 @@ public class ApiServer(string apiUrl) : IApiServer Log.Debug("Check authentication"); var isAuthenticated = false; if (!string.IsNullOrWhiteSpace(authKey) && DecodeAuthKey(authKey) is string authKeyDecoded) - isAuthenticated = CheckAuthentication(authKeyDecoded); + isAuthenticated = CheckAuthentication(authKeyDecoded, handler); else authKeyDecoded = null!; if (attribute.RequiesAuth && !isAuthenticated) @@ -278,11 +278,11 @@ public class ApiServer(string apiUrl) : IApiServer return Serializer; } - protected virtual bool CheckAuthentication(string authKey) + protected virtual bool CheckAuthentication(string authKey, Delegate? handler) { if (OnCheckAuthentication != null) { - var args = new ApiAuthCheckEventArgs(authKey); + var args = new ApiAuthCheckEventArgs(authKey, handler); OnCheckAuthentication?.Invoke(this, args); return args.Valid; }