diff --git a/OF DL.Core/Services/ApiService.cs b/OF DL.Core/Services/ApiService.cs index 09efb41..c6126bd 100644 --- a/OF DL.Core/Services/ApiService.cs +++ b/OF DL.Core/Services/ApiService.cs @@ -147,6 +147,12 @@ public class ApiService(IAuthService authService, IConfigService configService, return headers; } + private bool HasSignedRequestAuth() + { + Auth? currentAuth = authService.CurrentAuth; + return currentAuth is { UserId: not null, Cookie: not null, UserAgent: not null, XBc: not null }; + } + /// /// Retrieves user information from the API. @@ -157,6 +163,11 @@ public class ApiService(IAuthService authService, IConfigService configService, { Log.Debug($"Calling GetUserInfo: {endpoint}"); + if (!HasSignedRequestAuth()) + { + return null; + } + try { UserEntities.User user = new(); @@ -197,6 +208,11 @@ public class ApiService(IAuthService authService, IConfigService configService, /// A JSON object when available. public async Task GetUserInfoById(string endpoint) { + if (!HasSignedRequestAuth()) + { + return null; + } + try { HttpClient client = new(); @@ -272,6 +288,11 @@ public class ApiService(IAuthService authService, IConfigService configService, { Log.Debug("Calling GetLists"); + if (!HasSignedRequestAuth()) + { + return null; + } + try { int offset = 0; @@ -333,6 +354,11 @@ public class ApiService(IAuthService authService, IConfigService configService, { Log.Debug($"Calling GetListUsers - {endpoint}"); + if (!HasSignedRequestAuth()) + { + return null; + } + try { int offset = 0; @@ -393,6 +419,11 @@ public class ApiService(IAuthService authService, IConfigService configService, { Log.Debug($"Calling GetMedia - {username}"); + if (!HasSignedRequestAuth()) + { + return null; + } + try { Dictionary returnUrls = new(); @@ -2928,6 +2959,11 @@ public class ApiService(IAuthService authService, IConfigService configService, private async Task?> GetAllSubscriptions(Dictionary getParams, string endpoint, bool includeRestricted) { + if (!HasSignedRequestAuth()) + { + return null; + } + try { Dictionary users = new();