#427 Replace registration settings with one registration type property

- Merge "useEmail" / "usePasswordConfirmation" / "useEmailConfirmation" settings into enum property
- Migrate old settings
This commit is contained in:
ljacqu 2016-12-15 22:36:54 +01:00
parent 811ceaf7ff
commit f9acb3cca1
15 changed files with 157 additions and 103 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Sun Nov 13 13:34:49 CET 2016. See docs/config/config.tpl.md -->
<!-- File auto-generated on Thu Dec 15 22:27:25 CET 2016. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -102,10 +102,14 @@ settings:
# Message language, available languages:
# https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md
messagesLanguage: 'en'
# Log level: INFO, FINE, DEBUG. Use INFO for general messages,
# FINE for some additional detailed ones (like password failed),
# and DEBUG for debugging
logLevel: 'FINE'
# By default we schedule async tasks when talking to the database. If you want
# typical communication with the database to happen synchronously, set this to false
useAsyncTasks: true
restrictions:
# Keeps collisions disabled for logged players
# Works only with MC 1.9
keepCollisionsDisabled: false
# Can not authenticated players chat?
# Keep in mind that this feature also blocks all commands not
# listed in the list below.
@ -158,7 +162,7 @@ settings:
# Should unregistered players be kicked immediately?
kickNonRegistered: false
# Should players be kicked on wrong password?
kickOnWrongPassword: false
kickOnWrongPassword: true
# Should not logged in players be teleported to the spawn?
# After the authentication they will be teleported back to
# their normal position.
@ -176,14 +180,10 @@ settings:
# How far can unregistered players walk?
# Set to 0 for unlimited radius
allowedMovementRadius: 100
# Enable double check of password when you register
# when it's true, registration requires that kind of command:
# /register <password> <confirmPassword>
enablePasswordConfirmation: true
# Should we protect the player inventory before logging in? Requires ProtocolLib.
ProtectInventoryBeforeLogIn: true
# Should we deny the tabcomplete feature before logging in? Requires ProtocolLib.
DenyTabCompleteBeforeLogin: true
DenyTabCompleteBeforeLogin: false
# Should we display all other accounts from a player when he joins?
# permission: /authme.admin.accounts
displayOtherAccounts: true
@ -204,13 +204,6 @@ settings:
# Command to run when a user has more accounts than the configured threshold.
# Available variables: %playername%, %playerip%
otherAccountsCmd: 'say The player %playername% with ip %playerip% has multiple accounts!'
# Log level: INFO, FINE, DEBUG. Use INFO for general messages,
# FINE for some additional detailed ones (like password failed),
# and DEBUG for debugging
logLevel: 'FINE'
# By default we schedule async tasks when talking to the database. If you want
# typical communication with the database to happen synchronously, set this to false
useAsyncTasks: true
GameMode:
# Force survival gamemode when player joins?
ForceSurvivalMode: false
@ -240,9 +233,10 @@ settings:
# Otherwise your group will be wiped and the player will join in the default group []!
# Example unLoggedinGroup: NotLogged
unLoggedinGroup: 'unLoggedinGroup'
# Possible values: MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB,
# MYBB, IPB3, PHPFUSION, SMF, XENFORO, SALTED2MD5, JOOMLA, BCRYPT, WBB3, SHA512,
# DOUBLEMD5, PBKDF2, PBKDF2DJANGO, WORDPRESS, ROYALAUTH, CUSTOM (for developers only)
# Possible values: SHA256, BCRYPT, BCRYPT2Y, PBKDF2, SALTEDSHA512, WHIRLPOOL,
# MYBB, IPB3, PHPBB, PHPFUSION, SMF, XENFORO, XAUTH, JOOMLA, WBB3, WBB4, MD5VB,
# PBKDF2DJANGO, WORDPRESS, ROYALAUTH, CUSTOM (for developers only). See full list at
# https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/hash_algorithms.md
passwordHash: 'SHA256'
# Salt length for the SALTED2MD5 MD5(MD5(password)+salt)
doubleMD5SaltLength: 8
@ -252,6 +246,8 @@ settings:
# legacyHashes:
# - 'SHA1'
legacyHashes: []
# Number of rounds to use if passwordHash is set to PBKDF2. Default is 10000
pbkdf2Rounds: 10000
# Prevent unsafe passwords from being used; put them in lowercase!
# You should always set 'help' as unsafePassword due to possible conflicts.
# unsafePasswords:
@ -275,27 +271,14 @@ settings:
# Only registered and logged in players can play.
# See restrictions for exceptions
force: true
# Do we replace password registration by an email registration method?
enableEmailRegistrationSystem: false
# Enable double check of email when you register
# when it's true, registration requires that kind of command:
# /register <email> <confirmEmail>
doubleEmailCheck: false
# Type of registration: PASSWORD, PASSWORD_WITH_CONFIRMATION, EMAIL
# EMAIL_WITH_CONFIRMATION, PASSWORD_WITH_EMAIL
type: 'PASSWORD_WITH_CONFIRMATION'
# Do we force kick a player after a successful registration?
# Do not use with login feature below
forceKickAfterRegister: false
# Does AuthMe need to enforce a /login after a successful registration?
forceLoginAfterRegister: false
# Force these commands after /login, without any '/', use %p to replace with player name
forceCommands: []
# Force these commands after /login as service console, without any '/'.
# Use %p to replace with player name
forceCommandsAsConsole: []
# Force these commands after /register, without any '/', use %p to replace with player name
forceRegisterCommands: []
# Force these commands after /register as a server console, without any '/'.
# Use %p to replace with player name
forceRegisterCommandsAsConsole: []
# Enable to display the welcome message (welcome.txt) after a login
# You can use colors in this welcome.txt + some replaced strings:
# {PLAYER}: player name, {ONLINE}: display number of online players,
@ -318,7 +301,7 @@ settings:
applyBlindEffect: false
# Do we need to prevent people to login with another case?
# If Xephi is registered, then Xephi can login, but not XEPHI/xephi/XePhI
preventOtherCase: false
preventOtherCase: true
permission:
# Take care with this option; if you want
# to use group switching of AuthMe
@ -363,7 +346,7 @@ Hooks:
# Send player to this BungeeCord server after register/login
sendPlayerTo: ''
# Do we need to disable Essentials SocialSpy on join?
disableSocialSpy: true
disableSocialSpy: false
# Do we need to force /motd Essentials command on join?
useEssentialsMotd: false
GroupOptions:
@ -464,4 +447,4 @@ To change settings on a running server, save your changes to config.yml and use
---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Nov 13 13:34:49 CET 2016
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Thu Dec 15 22:27:25 CET 2016

View File

@ -9,6 +9,8 @@ import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType;
import fr.xephi.authme.settings.properties.RegistrationArgumentType.Execution;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.RandomStringUtils;
import org.bukkit.entity.Player;
@ -17,9 +19,7 @@ import javax.inject.Inject;
import java.util.List;
import static fr.xephi.authme.settings.properties.EmailSettings.RECOVERY_PASSWORD_LENGTH;
import static fr.xephi.authme.settings.properties.RegistrationSettings.ENABLE_CONFIRM_EMAIL;
import static fr.xephi.authme.settings.properties.RegistrationSettings.USE_EMAIL_REGISTRATION;
import static fr.xephi.authme.settings.properties.RestrictionSettings.ENABLE_PASSWORD_CONFIRMATION;
import static fr.xephi.authme.settings.properties.RegistrationSettings.REGISTRATION_TYPE;
/**
* Command for /register.
@ -47,13 +47,13 @@ public class RegisterCommand extends PlayerCommand {
}
// Ensure that there is 1 argument, or 2 if confirmation is required
final boolean useConfirmation = isConfirmationRequired();
if (arguments.isEmpty() || useConfirmation && arguments.size() < 2) {
RegistrationArgumentType registerType = commonService.getProperty(REGISTRATION_TYPE);
if (registerType.getRequiredNumberOfArgs() > arguments.size()) {
commonService.send(player, MessageKey.USAGE_REGISTER);
return;
}
if (commonService.getProperty(USE_EMAIL_REGISTRATION)) {
if (registerType.getExecution() == Execution.EMAIL) {
handleEmailRegistration(player, arguments);
} else {
handlePasswordRegistration(player, arguments);
@ -66,7 +66,8 @@ public class RegisterCommand extends PlayerCommand {
}
private void handlePasswordRegistration(Player player, List<String> arguments) {
if (commonService.getProperty(ENABLE_PASSWORD_CONFIRMATION) && !arguments.get(0).equals(arguments.get(1))) {
if (commonService.getProperty(REGISTRATION_TYPE) == RegistrationArgumentType.PASSWORD_WITH_CONFIRMATION
&& !arguments.get(0).equals(arguments.get(1))) {
commonService.send(player, MessageKey.PASSWORD_MATCH_ERROR);
} else {
management.performRegister(player, arguments.get(0), "", true);
@ -84,22 +85,12 @@ public class RegisterCommand extends PlayerCommand {
final String email = arguments.get(0);
if (!validationService.validateEmail(email)) {
commonService.send(player, MessageKey.INVALID_EMAIL);
} else if (commonService.getProperty(ENABLE_CONFIRM_EMAIL) && !email.equals(arguments.get(1))) {
} else if (commonService.getProperty(REGISTRATION_TYPE) == RegistrationArgumentType.EMAIL_WITH_CONFIRMATION
&& !email.equals(arguments.get(1))) {
commonService.send(player, MessageKey.USAGE_REGISTER);
} else {
String thePass = RandomStringUtils.generate(commonService.getProperty(RECOVERY_PASSWORD_LENGTH));
management.performRegister(player, thePass, email, true);
}
}
/**
* Return whether the password or email has to be confirmed.
*
* @return True if the confirmation is needed, false otherwise
*/
private boolean isConfirmationRequired() {
return commonService.getProperty(USE_EMAIL_REGISTRATION)
? commonService.getProperty(ENABLE_CONFIRM_EMAIL)
: commonService.getProperty(ENABLE_PASSWORD_CONFIRMATION);
}
}

View File

@ -9,6 +9,7 @@ import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType.Execution;
import org.bukkit.entity.Player;
import javax.inject.Inject;
@ -63,7 +64,7 @@ public class AsyncAddEmail implements AsynchronousProcess {
private void sendUnloggedMessage(Player player) {
if (dataSource.isAuthAvailable(player.getName())) {
service.send(player, MessageKey.LOGIN_MESSAGE);
} else if (service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)) {
} else if (service.getProperty(RegistrationSettings.REGISTRATION_TYPE).getExecution() == Execution.EMAIL) {
service.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
} else {
service.send(player, MessageKey.REGISTER_MESSAGE);

View File

@ -8,6 +8,7 @@ import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType.Execution;
import org.bukkit.entity.Player;
import javax.inject.Inject;
@ -66,7 +67,7 @@ public class AsyncChangeEmail implements AsynchronousProcess {
private void outputUnloggedMessage(Player player) {
if (dataSource.isAuthAvailable(player.getName())) {
service.send(player, MessageKey.LOGIN_MESSAGE);
} else if (service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)) {
} else if (service.getProperty(RegistrationSettings.REGISTRATION_TYPE).getExecution() == Execution.EMAIL) {
service.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
} else {
service.send(player, MessageKey.REGISTER_MESSAGE);

View File

@ -9,6 +9,8 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.output.LogLevel;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType;
import fr.xephi.authme.settings.properties.SecuritySettings;
import javax.inject.Inject;
@ -67,6 +69,7 @@ public class SettingsMigrationService extends PlainMigrationService {
| changeBooleanSettingToLogLevelProperty(resource)
| hasOldHelpHeaderProperty(resource)
| hasSupportOldPasswordProperty(resource)
| convertToRegistrationType(resource)
|| hasDeprecatedProperties(resource);
}
@ -224,6 +227,34 @@ public class SettingsMigrationService extends PlainMigrationService {
return false;
}
private static boolean convertToRegistrationType(PropertyResource resource) {
if (RegistrationSettings.REGISTRATION_TYPE.isPresent(resource)) {
return false;
}
boolean useEmail = newProperty("settings.registration.enableEmailRegistrationSystem", false).getValue(resource);
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;
}
ConsoleLogger.warning("Merging old registration settings into '"
+ RegistrationSettings.REGISTRATION_TYPE.getPath() + "'");
resource.setValue(RegistrationSettings.REGISTRATION_TYPE.getPath(), registerType);
return true;
}
/**
* Checks for an old property path and moves it to a new path if present.
*

View File

@ -0,0 +1,59 @@
package fr.xephi.authme.settings.properties;
/**
* Type of arguments used for the login command.
*/
public enum RegistrationArgumentType {
/** /register [password] */
PASSWORD(Execution.PASSWORD, 1),
/** /register [password] [password] */
PASSWORD_WITH_CONFIRMATION(Execution.PASSWORD, 2),
/** /register [email] */
EMAIL(Execution.EMAIL, 1),
/** /register [email] [email] */
EMAIL_WITH_CONFIRMATION(Execution.EMAIL, 2);
// TODO #427: PASSWORD_WITH_EMAIL(PASSWORD, 2);
private final Execution execution;
private final int requiredNumberOfArgs;
/**
* Constructor.
*
* @param execution the registration process
* @param requiredNumberOfArgs the required number of arguments
*/
RegistrationArgumentType(Execution execution, int requiredNumberOfArgs) {
this.execution = execution;
this.requiredNumberOfArgs = requiredNumberOfArgs;
}
/**
* @return the registration execution that is used for this argument type
*/
public Execution getExecution() {
return execution;
}
/**
* @return number of arguments required to process the register command
*/
public int getRequiredNumberOfArgs() {
return requiredNumberOfArgs;
}
/**
* Registration execution (the type of registration).
*/
public enum Execution {
PASSWORD,
EMAIL
}
}

View File

@ -24,16 +24,12 @@ public class RegistrationSettings implements SettingsHolder {
public static final Property<Boolean> FORCE =
newProperty("settings.registration.force", true);
@Comment("Do we replace password registration by an email registration method?")
public static final Property<Boolean> USE_EMAIL_REGISTRATION =
newProperty("settings.registration.enableEmailRegistrationSystem", false);
@Comment({
"Enable double check of email when you register",
"when it's true, registration requires that kind of command:",
"/register <email> <confirmEmail>"})
public static final Property<Boolean> ENABLE_CONFIRM_EMAIL =
newProperty("settings.registration.doubleEmailCheck", false);
"Type of registration: PASSWORD, PASSWORD_WITH_CONFIRMATION, EMAIL",
"EMAIL_WITH_CONFIRMATION, PASSWORD_WITH_EMAIL"
})
public static final Property<RegistrationArgumentType> REGISTRATION_TYPE =
newProperty(RegistrationArgumentType.class, "settings.registration.type", RegistrationArgumentType.PASSWORD_WITH_CONFIRMATION);
@Comment({
"Do we force kick a player after a successful registration?",

View File

@ -126,13 +126,6 @@ public class RestrictionSettings implements SettingsHolder {
public static final Property<Integer> ALLOWED_MOVEMENT_RADIUS =
newProperty("settings.restrictions.allowedMovementRadius", 100);
@Comment({
"Enable double check of password when you register",
"when it's true, registration requires that kind of command:",
"/register <password> <confirmPassword>"})
public static final Property<Boolean> ENABLE_PASSWORD_CONFIRMATION =
newProperty("settings.restrictions.enablePasswordConfirmation", true);
@Comment("Should we protect the player inventory before logging in? Requires ProtocolLib.")
public static final Property<Boolean> PROTECT_INVENTORY_BEFORE_LOGIN =
newProperty("settings.restrictions.ProtectInventoryBeforeLogIn", true);

View File

@ -6,10 +6,11 @@ import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.data.limbo.LimboPlayer;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType.Execution;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
@ -95,7 +96,7 @@ public class LimboPlayerTaskManager {
if (isRegistered) {
return MessageKey.LOGIN_MESSAGE;
} else {
return settings.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)
return settings.getProperty(RegistrationSettings.REGISTRATION_TYPE).getExecution() == Execution.EMAIL
? MessageKey.REGISTER_EMAIL_MESSAGE
: MessageKey.REGISTER_MESSAGE;
}

View File

@ -9,7 +9,7 @@ import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
@ -63,8 +63,7 @@ public class RegisterCommandTest {
@Before
public void linkMocksAndProvideSettingDefaults() {
given(commandService.getProperty(SecuritySettings.PASSWORD_HASH)).willReturn(HashAlgorithm.BCRYPT);
given(commandService.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(false);
given(commandService.getProperty(RestrictionSettings.ENABLE_PASSWORD_CONFIRMATION)).willReturn(false);
given(commandService.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.PASSWORD);
}
@Test
@ -110,7 +109,7 @@ public class RegisterCommandTest {
@Test
public void shouldReturnErrorForMissingConfirmation() {
// given
given(commandService.getProperty(RestrictionSettings.ENABLE_PASSWORD_CONFIRMATION)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.PASSWORD_WITH_CONFIRMATION);
Player player = mock(Player.class);
// when
@ -124,8 +123,7 @@ public class RegisterCommandTest {
@Test
public void shouldReturnErrorForMissingEmailConfirmation() {
// given
given(commandService.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.ENABLE_CONFIRM_EMAIL)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.EMAIL_WITH_CONFIRMATION);
Player player = mock(Player.class);
// when
@ -139,8 +137,7 @@ public class RegisterCommandTest {
@Test
public void shouldThrowErrorForMissingEmailConfiguration() {
// given
given(commandService.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.ENABLE_CONFIRM_EMAIL)).willReturn(false);
given(commandService.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.EMAIL);
given(sendMailSsl.hasAllInformation()).willReturn(false);
Player player = mock(Player.class);
@ -158,9 +155,7 @@ public class RegisterCommandTest {
// given
String playerMail = "player@example.org";
given(validationService.validateEmail(playerMail)).willReturn(false);
given(commandService.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.ENABLE_CONFIRM_EMAIL)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.EMAIL_WITH_CONFIRMATION);
given(sendMailSsl.hasAllInformation()).willReturn(true);
Player player = mock(Player.class);
@ -178,9 +173,7 @@ public class RegisterCommandTest {
// given
String playerMail = "bobber@bobby.org";
given(validationService.validateEmail(playerMail)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.ENABLE_CONFIRM_EMAIL)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.EMAIL_WITH_CONFIRMATION);
given(sendMailSsl.hasAllInformation()).willReturn(true);
Player player = mock(Player.class);
@ -201,8 +194,7 @@ public class RegisterCommandTest {
int passLength = 7;
given(commandService.getProperty(EmailSettings.RECOVERY_PASSWORD_LENGTH)).willReturn(passLength);
given(commandService.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.ENABLE_CONFIRM_EMAIL)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.EMAIL_WITH_CONFIRMATION);
given(sendMailSsl.hasAllInformation()).willReturn(true);
Player player = mock(Player.class);
@ -218,7 +210,7 @@ public class RegisterCommandTest {
@Test
public void shouldRejectInvalidPasswordConfirmation() {
// given
given(commandService.getProperty(RestrictionSettings.ENABLE_PASSWORD_CONFIRMATION)).willReturn(true);
given(commandService.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.PASSWORD_WITH_CONFIRMATION);
Player player = mock(Player.class);
// when

View File

@ -8,6 +8,7 @@ import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType;
import org.bukkit.entity.Player;
import org.junit.BeforeClass;
import org.junit.Test;
@ -172,7 +173,7 @@ public class AsyncAddEmailTest {
given(player.getName()).willReturn("user");
given(playerCache.isAuthenticated("user")).willReturn(false);
given(dataSource.isAuthAvailable("user")).willReturn(false);
given(service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
given(service.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.EMAIL);
// when
asyncAddEmail.addEmail(player, "test@mail.com");
@ -188,7 +189,7 @@ public class AsyncAddEmailTest {
given(player.getName()).willReturn("user");
given(playerCache.isAuthenticated("user")).willReturn(false);
given(dataSource.isAuthAvailable("user")).willReturn(false);
given(service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(false);
given(service.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.PASSWORD_WITH_CONFIRMATION);
// when
asyncAddEmail.addEmail(player, "test@mail.com");

View File

@ -7,6 +7,7 @@ import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType;
import org.bukkit.entity.Player;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -184,7 +185,7 @@ public class AsyncChangeEmailTest {
given(player.getName()).willReturn("Bobby");
given(playerCache.isAuthenticated("bobby")).willReturn(false);
given(dataSource.isAuthAvailable("Bobby")).willReturn(false);
given(service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
given(service.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.EMAIL_WITH_CONFIRMATION);
// when
process.changeEmail(player, "old@mail.tld", "new@mail.tld");
@ -201,7 +202,7 @@ public class AsyncChangeEmailTest {
given(player.getName()).willReturn("Bobby");
given(playerCache.isAuthenticated("bobby")).willReturn(false);
given(dataSource.isAuthAvailable("Bobby")).willReturn(false);
given(service.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(false);
given(service.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.PASSWORD);
// when
process.changeEmail(player, "old@mail.tld", "new@mail.tld");

View File

@ -6,6 +6,7 @@ import com.google.common.io.Files;
import fr.xephi.authme.TestHelper;
import fr.xephi.authme.output.LogLevel;
import fr.xephi.authme.settings.properties.AuthMeSettingsRetriever;
import fr.xephi.authme.settings.properties.RegistrationArgumentType;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
@ -18,6 +19,7 @@ import java.nio.charset.StandardCharsets;
import static fr.xephi.authme.TestHelper.getJarFile;
import static fr.xephi.authme.settings.properties.PluginSettings.LOG_LEVEL;
import static fr.xephi.authme.settings.properties.RegistrationSettings.DELAY_JOIN_MESSAGE;
import static fr.xephi.authme.settings.properties.RegistrationSettings.REGISTRATION_TYPE;
import static fr.xephi.authme.settings.properties.RestrictionSettings.ALLOWED_NICKNAME_CHARACTERS;
import static fr.xephi.authme.settings.properties.RestrictionSettings.FORCE_SPAWN_LOCATION_AFTER_LOGIN;
import static fr.xephi.authme.settings.properties.RestrictionSettings.FORCE_SPAWN_ON_WORLDS;
@ -59,6 +61,7 @@ public class SettingsMigrationServiceTest {
assertThat(settings.getProperty(FORCE_SPAWN_LOCATION_AFTER_LOGIN), equalTo(true));
assertThat(settings.getProperty(FORCE_SPAWN_ON_WORLDS), contains("survival", "survival_nether", "creative"));
assertThat(settings.getProperty(LOG_LEVEL), equalTo(LogLevel.INFO));
assertThat(settings.getProperty(REGISTRATION_TYPE), equalTo(RegistrationArgumentType.EMAIL_WITH_CONFIRMATION));
// Check migration of old setting to email.html
assertThat(Files.readLines(new File(dataFolder, "email.html"), StandardCharsets.UTF_8),

View File

@ -9,6 +9,7 @@ import fr.xephi.authme.message.Messages;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RegistrationArgumentType;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
@ -67,7 +68,7 @@ public class LimboPlayerTaskManagerTest {
given(messages.retrieve(key)).willReturn(new String[]{"Please register!"});
int interval = 12;
given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(interval);
given(settings.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
given(settings.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.EMAIL_WITH_CONFIRMATION);
// when
limboPlayerTaskManager.registerMessageTask(name, false);
@ -123,7 +124,7 @@ public class LimboPlayerTaskManagerTest {
.willReturn(new String[]{"Please register", "Use /register"});
given(settings.getProperty(RegistrationSettings.MESSAGE_INTERVAL)).willReturn(8);
given(settings.getProperty(RegistrationSettings.USE_EMAIL_REGISTRATION)).willReturn(true);
given(settings.getProperty(RegistrationSettings.REGISTRATION_TYPE)).willReturn(RegistrationArgumentType.EMAIL);
// when
limboPlayerTaskManager.registerMessageTask(name, false);

View File

@ -218,11 +218,11 @@ settings:
# See restrictions for exceptions
force: true
# Does we replace password registration by an Email registration method ?
enableEmailRegistrationSystem: false
enableEmailRegistrationSystem: true
# Enable double check of email when you register
# when it's true, registration require that kind of command:
# /register <email> <confirmEmail>
doubleEmailCheck: false
doubleEmailCheck: true
# Do we force kicking player after a successful registration ?
# Do not use with login feature below
forceKickAfterRegister: false