mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-10 04:30:58 +01:00
Fix #416
This commit is contained in:
parent
2081fd7e34
commit
6855fb93fc
@ -1,13 +1,13 @@
|
|||||||
package fr.xephi.authme.process.email;
|
package fr.xephi.authme.process.email;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.output.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.output.Messages;
|
||||||
|
import fr.xephi.authme.permission.PlayerPermission;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,66 +35,52 @@ public class AsyncChangeEmail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void process() {
|
public void process() {
|
||||||
try {
|
String playerName = player.getName().toLowerCase();
|
||||||
String playerName = player.getName().toLowerCase();
|
if (PlayerCache.getInstance().isAuthenticated(playerName)) {
|
||||||
|
if (!newEmail.equals(newEmailVerify)) {
|
||||||
if (Settings.getmaxRegPerEmail > 0) {
|
m.send(player, MessageKey.CONFIRM_EMAIL_MESSAGE);
|
||||||
if (!plugin.getPermissionsManager().hasPermission(player, PlayerPermission.ALLOW_MULTIPLE_ACCOUNTS)
|
return;
|
||||||
&& plugin.getDataSource().getAllAuthsByEmail(newEmail).size() >= Settings.getmaxRegPerEmail) {
|
}
|
||||||
m.send(player, MessageKey.MAX_REGISTER_EXCEEDED);
|
PlayerAuth auth = PlayerCache.getInstance().getAuth(playerName);
|
||||||
|
String currentEmail = auth.getEmail();
|
||||||
|
if (oldEmail != null) {
|
||||||
|
if (StringUtils.isEmpty(currentEmail) || currentEmail.equals("your@email.com")) {
|
||||||
|
m.send(player, MessageKey.USAGE_ADD_EMAIL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!oldEmail.equals(currentEmail)) {
|
||||||
|
m.send(player, MessageKey.INVALID_OLD_EMAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Settings.isEmailCorrect(newEmail)) {
|
||||||
if (PlayerCache.getInstance().isAuthenticated(playerName)) {
|
m.send(player, MessageKey.INVALID_NEW_EMAIL);
|
||||||
if (!newEmail.equals(newEmailVerify)) {
|
return;
|
||||||
m.send(player, MessageKey.CONFIRM_EMAIL_MESSAGE);
|
}
|
||||||
return;
|
auth.setEmail(newEmail);
|
||||||
}
|
if (!plugin.getDataSource().updateEmail(auth)) {
|
||||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(playerName);
|
m.send(player, MessageKey.ERROR);
|
||||||
if (oldEmail != null) {
|
auth.setEmail(currentEmail);
|
||||||
if (auth.getEmail() == null || auth.getEmail().equals("your@email.com") || auth.getEmail().isEmpty()) {
|
return;
|
||||||
m.send(player, MessageKey.USAGE_ADD_EMAIL);
|
}
|
||||||
return;
|
PlayerCache.getInstance().updatePlayer(auth);
|
||||||
}
|
if (oldEmail == null) {
|
||||||
if (!oldEmail.equals(auth.getEmail())) {
|
m.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
||||||
m.send(player, MessageKey.INVALID_OLD_EMAIL);
|
player.sendMessage(auth.getEmail());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
m.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
||||||
if (!Settings.isEmailCorrect(newEmail)) {
|
} else {
|
||||||
m.send(player, MessageKey.INVALID_NEW_EMAIL);
|
if (plugin.getDataSource().isAuthAvailable(playerName)) {
|
||||||
return;
|
m.send(player, MessageKey.LOGIN_MESSAGE);
|
||||||
}
|
|
||||||
String old = auth.getEmail();
|
|
||||||
auth.setEmail(newEmail);
|
|
||||||
if (!plugin.getDataSource().updateEmail(auth)) {
|
|
||||||
m.send(player, MessageKey.ERROR);
|
|
||||||
auth.setEmail(old);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PlayerCache.getInstance().updatePlayer(auth);
|
|
||||||
if (oldEmail == null) {
|
|
||||||
m.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
|
||||||
player.sendMessage(auth.getEmail());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m.send(player, MessageKey.EMAIL_CHANGED_SUCCESS);
|
|
||||||
} else {
|
} else {
|
||||||
if (plugin.getDataSource().isAuthAvailable(playerName)) {
|
if (Settings.emailRegistration) {
|
||||||
m.send(player, MessageKey.LOGIN_MESSAGE);
|
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
if (Settings.emailRegistration) {
|
m.send(player, MessageKey.REGISTER_MESSAGE);
|
||||||
m.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
|
||||||
} else {
|
|
||||||
m.send(player, MessageKey.REGISTER_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
ConsoleLogger.showError(e.getMessage());
|
|
||||||
ConsoleLogger.writeStackTrace(e);
|
|
||||||
m.send(player, MessageKey.ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user