Skip IP check for API registration

This commit is contained in:
games647 2018-03-29 14:08:33 +02:00
parent f752b9d7a7
commit ee41d92216
No known key found for this signature in database
GPG Key ID: BFC68C8708713A88

View File

@ -49,7 +49,7 @@ public class AsyncRegister implements AsynchronousProcess {
* @param <P> parameters type * @param <P> parameters type
*/ */
public <P extends RegistrationParameters> void register(RegistrationMethod<P> variant, P parameters) { public <P extends RegistrationParameters> void register(RegistrationMethod<P> variant, P parameters) {
if (preRegisterCheck(parameters.getPlayer())) { if (preRegisterCheck(variant, parameters.getPlayer())) {
RegistrationExecutor<P> executor = registrationExecutorFactory.getSingleton(variant.getExecutorClass()); RegistrationExecutor<P> executor = registrationExecutorFactory.getSingleton(variant.getExecutorClass());
if (executor.isRegistrationAdmitted(parameters)) { if (executor.isRegistrationAdmitted(parameters)) {
executeRegistration(parameters, executor); executeRegistration(parameters, executor);
@ -57,7 +57,7 @@ public class AsyncRegister implements AsynchronousProcess {
} }
} }
private boolean preRegisterCheck(Player player) { private boolean preRegisterCheck(RegistrationMethod<?> variant, Player player) {
final String name = player.getName().toLowerCase(); final String name = player.getName().toLowerCase();
if (playerCache.isAuthenticated(name)) { if (playerCache.isAuthenticated(name)) {
service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR); service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
@ -70,7 +70,7 @@ public class AsyncRegister implements AsynchronousProcess {
return false; return false;
} }
return isPlayerIpAllowedToRegister(player); return variant == RegistrationMethod.API_REGISTRATION || isPlayerIpAllowedToRegister(player);
} }
/** /**