diff --git a/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java b/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java index 83a0e5b2..31580db3 100644 --- a/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommand.java @@ -8,6 +8,7 @@ import fr.xephi.authme.process.Management; import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.ValidationService; import fr.xephi.authme.service.ValidationService.ValidationResult; +import fr.xephi.authme.settings.properties.SecuritySettings; import org.bukkit.entity.Player; import javax.inject.Inject; @@ -42,11 +43,14 @@ public class ChangePasswordCommand extends PlayerCommand { commonService.send(player, MessageKey.NOT_LOGGED_IN); return; } - // Check if the user has been verified or not - if (codeManager.isVerificationRequired(player)) { - codeManager.codeExistOrGenerateNew(name); - commonService.send(player, MessageKey.VERIFICATION_CODE_REQUIRED); - return; + + if (commonService.getProperty(SecuritySettings.CHANGE_PASSWORD_EMAIL_VERIFICATION_REQUIRED)) { + // Check if the user has been verified or not + if (codeManager.isVerificationRequired(player)) { + codeManager.codeExistOrGenerateNew(name); + commonService.send(player, MessageKey.VERIFICATION_CODE_REQUIRED); + return; + } } String oldPassword = arguments.get(0); diff --git a/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java b/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java index b1d7c4ae..fc560e3c 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java @@ -62,6 +62,11 @@ public final class SecuritySettings implements SettingsHolder { public static final Property HAVE_I_BEEN_PWNED_LIMIT = newProperty("Security.account.haveIBeenPwned.limit", 0); + @Comment({"Require email verification when changing password if email feature enabled.", + "Original behavior is true"}) + public static final Property CHANGE_PASSWORD_EMAIL_VERIFICATION_REQUIRED = + newProperty("Security.account.emailVerification.required", true); + @Comment("Enable captcha when a player uses wrong password too many times") public static final Property ENABLE_LOGIN_FAILURE_CAPTCHA = newProperty("Security.captcha.useCaptcha", false);