diff --git a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs index f48c7e7d..081614d6 100644 --- a/ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs +++ b/ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs @@ -35,18 +35,18 @@ public class ResourcesController : ControllerBase } [HttpGet("r/{hash}")] - public Task GetResource(string hash) + public IActionResult GetResource(string hash) { string path = FileHelper.GetResourcePath(hash); string fullPath = Path.GetFullPath(path); // Prevent directory traversal attacks - if (!fullPath.StartsWith(FileHelper.FullResourcePath)) return Task.FromResult(this.BadRequest()); + if (!fullPath.StartsWith(FileHelper.FullResourcePath)) return this.BadRequest(); - if (FileHelper.ResourceExists(hash)) return Task.FromResult(this.File(IOFile.OpenRead(path), "application/octet-stream")); + if (FileHelper.ResourceExists(hash)) return this.File(IOFile.OpenRead(path), "application/octet-stream"); - return Task.FromResult(this.NotFound()); + return this.NotFound(); } [HttpPost("upload/{hash}/unattributed")] diff --git a/ProjectLighthouse/Configuration/EmailEnforcementConfiguration.cs b/ProjectLighthouse/Configuration/EmailEnforcementConfiguration.cs index 56179d91..ee381926 100644 --- a/ProjectLighthouse/Configuration/EmailEnforcementConfiguration.cs +++ b/ProjectLighthouse/Configuration/EmailEnforcementConfiguration.cs @@ -6,21 +6,21 @@ namespace LBPUnion.ProjectLighthouse.Configuration; public class EmailEnforcementConfiguration : ConfigurationBase { - public override int ConfigVersion { get; set; } = 4; + public override int ConfigVersion { get; set; } = 1; public override string ConfigName { get; set; } = "enforce-email.yml"; public override bool NeedsConfiguration { get; set; } = false; - public bool EnableEmailEnforcement => false; - public bool EnableEmailBlacklist => false; + public bool EnableEmailEnforcement { get; set; } = false; + public bool EnableEmailBlacklist { get; set; } = false; // No blacklist by default, add path to blacklist - public string BlacklistFilePath => ""; + public string BlacklistFilePath { get; set; } = ""; // Endpoints to be blocked // This is kind of a random list so some may need to be added or removed - public HashSet BlockedEndpoints => new() + public HashSet BlockedEndpoints { get; set; } = new() { // Comments "rateUserComment", diff --git a/ProjectLighthouse/Helpers/EmailHelper.cs b/ProjectLighthouse/Helpers/EmailHelper.cs index 65124f96..92b5bb14 100644 --- a/ProjectLighthouse/Helpers/EmailHelper.cs +++ b/ProjectLighthouse/Helpers/EmailHelper.cs @@ -89,17 +89,17 @@ public static class SMTPHelper return false; // Don't even bother if there are no domains in blacklist (AKA file path is empty/invalid, or file itself is empty) - if (ServerConfiguration.Instance.EmailEnforcement.EnableEmailBlacklist && blacklistedDomains.Count > 0) - { - // Get domain by splitting at '@' character - string domain = email.Split('@')[1]; + if (!ServerConfiguration.Instance.EmailEnforcement.EnableEmailBlacklist || blacklistedDomains.Count <= 0) + return true; + + // Get domain by splitting at '@' character + string domain = email.Split('@')[1]; - // Return false if domain is found in blacklist - if (blacklistedDomains.Contains(domain)) - { - Logger.Info($"Invalid email address {email} submitted by user.", LogArea.Email); - return false; - } + // Return false if domain is found in blacklist + if (blacklistedDomains.Contains(domain)) + { + Logger.Info($"Invalid email address {email} submitted by user.", LogArea.Email); + return false; } return true;