#427 Define registration type with two options - one configuring the 2nd argument

- Split sole setting to two: one defining the registration type, and one defining what the register command should take as second argument
- Contains ugly code that will be fixed with a later issue
This commit is contained in:
ljacqu
2016-12-31 15:34:40 +01:00
parent d298e1c6f1
commit 0b4d7273f6
17 changed files with 264 additions and 106 deletions
@@ -8,8 +8,9 @@ import com.google.common.base.Objects;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.output.LogLevel;
import fr.xephi.authme.process.register.RegisterSecondaryArgument;
import fr.xephi.authme.process.register.RegistrationType;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@@ -232,25 +233,20 @@ public class SettingsMigrationService extends PlainMigrationService {
}
boolean useEmail = newProperty("settings.registration.enableEmailRegistrationSystem", false).getValue(resource);
RegistrationType registrationType = useEmail ? RegistrationType.EMAIL : RegistrationType.PASSWORD;
String useConfirmationPath = useEmail
? "settings.registration.doubleEmailCheck"
: "settings.restrictions.enablePasswordConfirmation";
boolean hasConfirmation = newProperty(useConfirmationPath, false).getValue(resource);
RegistrationArgumentType registerType;
if (useEmail) {
registerType = hasConfirmation
? RegistrationArgumentType.EMAIL_WITH_CONFIRMATION
: RegistrationArgumentType.EMAIL;
} else {
registerType = hasConfirmation
? RegistrationArgumentType.PASSWORD_WITH_CONFIRMATION
: RegistrationArgumentType.PASSWORD;
}
RegisterSecondaryArgument secondaryArgument = hasConfirmation
? RegisterSecondaryArgument.CONFIRMATION
: RegisterSecondaryArgument.NONE;
ConsoleLogger.warning("Merging old registration settings into '"
+ RegistrationSettings.REGISTRATION_TYPE.getPath() + "'");
resource.setValue(RegistrationSettings.REGISTRATION_TYPE.getPath(), registerType);
resource.setValue(RegistrationSettings.REGISTRATION_TYPE.getPath(), registrationType);
resource.setValue(RegistrationSettings.REGISTER_SECOND_ARGUMENT.getPath(), secondaryArgument);
return true;
}
@@ -3,6 +3,8 @@ package fr.xephi.authme.settings.properties;
import ch.jalu.configme.Comment;
import ch.jalu.configme.SettingsHolder;
import ch.jalu.configme.properties.Property;
import fr.xephi.authme.process.register.RegisterSecondaryArgument;
import fr.xephi.authme.process.register.RegistrationType;
import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
@@ -25,11 +27,21 @@ public class RegistrationSettings implements SettingsHolder {
newProperty("settings.registration.force", true);
@Comment({
"Type of registration: PASSWORD, PASSWORD_WITH_CONFIRMATION, EMAIL",
"EMAIL_WITH_CONFIRMATION, PASSWORD_WITH_EMAIL"
"Type of registration: PASSWORD or EMAIL",
"Password = account is registered with a password supplied by the user;",
"Email = password is generated and sent to the email provided by the user."
})
public static final Property<RegistrationArgumentType> REGISTRATION_TYPE =
newProperty(RegistrationArgumentType.class, "settings.registration.type", RegistrationArgumentType.PASSWORD_WITH_CONFIRMATION);
public static final Property<RegistrationType> REGISTRATION_TYPE =
newProperty(RegistrationType.class, "settings.registration.type", RegistrationType.PASSWORD);
@Comment({
"Second argument the /register command should take: NONE = no 2nd argument",
"CONFIRMATION = must repeat first argument (pass or email)",
"EMAIL_OPTIONAL = for password register: 2nd argument can be empty or have email address",
"EMAIL_MANDATORY = for password register: 2nd argument MUST be an email address"
})
public static final Property<RegisterSecondaryArgument> REGISTER_SECOND_ARGUMENT =
newProperty(RegisterSecondaryArgument.class, "settings.registration.secondArg", RegisterSecondaryArgument.CONFIRMATION);
@Comment({
"Do we force kick a player after a successful registration?",