mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-20 15:47:38 +01:00
#427 Make email option for /register [pass] [email] variant
This commit is contained in:
parent
dfad0211b7
commit
e905ff3013
@ -75,7 +75,7 @@ public class RegisterCommand extends PlayerCommand {
|
||||
RegistrationArgumentType registrationType = commonService.getProperty(REGISTRATION_TYPE);
|
||||
if (registrationType == PASSWORD_WITH_CONFIRMATION && !arguments.get(0).equals(arguments.get(1))) {
|
||||
commonService.send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
||||
} else if (registrationType == PASSWORD_WITH_EMAIL) {
|
||||
} else if (registrationType == PASSWORD_WITH_EMAIL && arguments.size() > 1) {
|
||||
handlePasswordWithEmailRegistration(player, arguments);
|
||||
} else {
|
||||
management.performRegister(player, registrationExecutorProvider
|
||||
|
@ -20,7 +20,7 @@ public enum RegistrationArgumentType {
|
||||
EMAIL_WITH_CONFIRMATION(Execution.EMAIL, 2, MessageKey.REGISTER_EMAIL_MESSAGE),
|
||||
|
||||
/** /register [password] [email] */
|
||||
PASSWORD_WITH_EMAIL(Execution.PASSWORD, 2, MessageKey.REGISTER_PASSWORD_EMAIL_MESSAGE);
|
||||
PASSWORD_WITH_EMAIL(Execution.PASSWORD, 1, MessageKey.REGISTER_PASSWORD_EMAIL_MESSAGE);
|
||||
|
||||
private final Execution execution;
|
||||
private final int requiredNumberOfArgs;
|
||||
|
@ -27,6 +27,8 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@ -276,17 +278,19 @@ public class RegisterCommandTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFailForInsufficientArguments() {
|
||||
public void shouldPerformNormalPasswordRegisterForOneArgument() {
|
||||
// given
|
||||
given(commonService.getProperty(RegistrationSettings.REGISTRATION_TYPE))
|
||||
.willReturn(RegistrationArgumentType.PASSWORD_WITH_EMAIL);
|
||||
Player player = mock(Player.class);
|
||||
RegistrationExecutor executor = mock(RegistrationExecutor.class);
|
||||
given(registrationExecutorProvider.getPasswordRegisterExecutor(eq(player), anyString())).willReturn(executor);
|
||||
|
||||
// when
|
||||
command.executeCommand(player, Collections.singletonList("myPass"));
|
||||
|
||||
// then
|
||||
verify(commonService).send(player, MessageKey.USAGE_REGISTER);
|
||||
verifyZeroInteractions(management);
|
||||
verify(registrationExecutorProvider).getPasswordRegisterExecutor(player, "myPass");
|
||||
verify(management).performRegister(player, executor);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user