#437 Add email should not allow to change email

- Create separate test for adding email
- Check that no email is yet registered for add email
This commit is contained in:
ljacqu
2016-01-13 22:08:40 +01:00
parent 4042ced5f2
commit 8ed8b32589
5 changed files with 112 additions and 55 deletions
@@ -2,6 +2,9 @@ package fr.xephi.authme.command.executable.email;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.StringUtils;
import org.bukkit.entity.Player;
import java.util.List;
@@ -10,9 +13,15 @@ public class AddEmailCommand extends PlayerCommand {
@Override
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
String playerMail = arguments.get(0);
String playerMailVerify = arguments.get(1);
String email = arguments.get(0);
String emailConfirmation = arguments.get(1);
commandService.getManagement().performAddEmail(player, playerMail, playerMailVerify);
if (StringUtils.isEmpty(email) || "your@email.com".equals(email) || !Settings.isEmailCorrect(email)) {
commandService.send(player, MessageKey.INVALID_EMAIL);
} else if (email.equals(emailConfirmation)) {
commandService.getManagement().performAddEmail(player, email);
} else {
commandService.send(player, MessageKey.CONFIRM_EMAIL_MESSAGE);
}
}
}