Add 2fa support
This commit is contained in:
@@ -4,9 +4,11 @@ import fr.xephi.authme.command.CommandService;
|
||||
import fr.xephi.authme.command.PlayerCommand;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@@ -15,6 +17,12 @@ public class RegisterCommand extends PlayerCommand {
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
if (Settings.getPasswordHash == HashAlgorithm.TWO_FACTOR) {
|
||||
//for two factor auth we don't need to check the usage
|
||||
commandService.getManagement().performRegister(player, "", "");
|
||||
return;
|
||||
}
|
||||
|
||||
if (arguments.isEmpty() || Settings.enablePasswordConfirmation && arguments.size() < 2) {
|
||||
commandService.send(player, MessageKey.USAGE_REGISTER);
|
||||
return;
|
||||
@@ -26,19 +34,23 @@ public class RegisterCommand extends PlayerCommand {
|
||||
commandService.send(player, MessageKey.USAGE_REGISTER);
|
||||
return;
|
||||
}
|
||||
|
||||
final String email = arguments.get(0);
|
||||
if (!Utils.isEmailCorrect(email, commandService.getSettings())) {
|
||||
commandService.send(player, MessageKey.INVALID_EMAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
final String thePass = RandomString.generate(Settings.getRecoveryPassLength);
|
||||
management.performRegister(player, thePass, email);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arguments.size() > 1 && Settings.enablePasswordConfirmation && !arguments.get(0).equals(arguments.get(1))) {
|
||||
commandService.send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
management.performRegister(player, arguments.get(0), "");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user