From 5c3f97f6c75d1d503eed9b6cdaff84bf8d2c9bf9 Mon Sep 17 00:00:00 2001 From: Xephi Date: Wed, 6 Aug 2014 18:03:32 +0200 Subject: [PATCH] Add emailBlackList domain --- .../authme/commands/RegisterCommand.java | 7 ++++-- .../fr/xephi/authme/settings/Settings.java | 22 +++++++++++++++++++ src/main/resources/config.yml | 3 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/main/java/fr/xephi/authme/commands/RegisterCommand.java b/src/main/java/fr/xephi/authme/commands/RegisterCommand.java index 70a150c54..6bd2b5cfd 100644 --- a/src/main/java/fr/xephi/authme/commands/RegisterCommand.java +++ b/src/main/java/fr/xephi/authme/commands/RegisterCommand.java @@ -28,6 +28,9 @@ public class RegisterCommand implements CommandExecutor { sender.sendMessage("Player Only! Use 'authme register ' instead"); return true; } + if (args.length == 0) { + m._(sender, "usage_reg"); + } if (!plugin.authmePermissible(sender, "authme." + label.toLowerCase())) { m._(sender, "no_perm"); return true; @@ -44,11 +47,11 @@ public class RegisterCommand implements CommandExecutor { return true; } } - if(!args[0].contains("@")) { + final String email = args[0]; + if(!Settings.isEmailCorrect(email)) { m._(player, "usage_reg"); return true; } - final String email = args[0]; RandomString rand = new RandomString(Settings.getRecoveryPassLength); final String thePass = rand.nextString(); plugin.management.performRegister(player, thePass, email); diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index 7fe72cc42..0c646ed30 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -47,6 +47,7 @@ public final class Settings extends YamlConfiguration { public static int purgeDelay = 60; public static List welcomeMsg = null; public static List unsafePasswords; + public static List emailBlacklist = null; public static Boolean isPermissionCheckEnabled, isRegistrationEnabled, isForcedRegistrationEnabled, isTeleportToSpawnEnabled, isSessionsEnabled, isChatAllowed, isAllowRestrictedIp, @@ -249,6 +250,7 @@ public void loadConfigOptions() { crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db"); getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters","[a-zA-Z0-9_?!@+&-]*"); applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false); + emailBlacklist = configFile.getStringList("Email.emailBlacklisted"); // Load the welcome message getWelcomeMessage(plugin); @@ -412,6 +414,7 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) { crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db"); getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters","[a-zA-Z0-9_?!@+&-]*"); applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false); + emailBlacklist = configFile.getStringList("Email.emailBlacklisted"); // Reload the welcome message getWelcomeMessage(AuthMe.getInstance()); @@ -536,6 +539,9 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) { set("settings.applyBlindEffect", false); changes = true; } + if(!contains("Email.emailBlacklisted")) { + set("Email.emailBlacklisted", new ArrayList()); + } if (changes) { plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me"); @@ -737,6 +743,22 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) { e.printStackTrace(); } } + + public static boolean isEmailCorrect(String email) { + boolean correct = true; + if (!email.contains("@")) + correct = false; + if (!email.equalsIgnoreCase("your@email.com")) + correct = false; + String emailDomain = email.split("@")[1]; + for (String domain : emailBlacklist) { + if (domain.equalsIgnoreCase(emailDomain)) { + correct = false; + break; + } + } + return correct; + } public enum messagesLang { en, de, br, cz, pl, fr, uk, ru, hu, sk, es, fi, zhtw, zhhk, zhcn, lt, it, ko, pt, nl, gl diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c03e22ac9..80481c1ea 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -359,6 +359,9 @@ Email: recallPlayers: false # Delay in minute for the recall scheduler delayRecall: 5 + # Blacklist these domain for emails + emailBlacklisted: + - 10minutemail.com Hooks: # Do we need to hook with multiverse for spawn checking? multiverse: true