#527 Persist email after changing it

This commit is contained in:
ljacqu 2016-02-19 21:47:52 +01:00
parent 964abdc0c5
commit 6f694cf818
2 changed files with 11 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package fr.xephi.authme.process.email;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
@ -46,12 +47,15 @@ public class AsyncAddEmail {
messages.send(player, MessageKey.INVALID_EMAIL);
} else if (dataSource.isEmailStored(email)) {
messages.send(player, MessageKey.EMAIL_ALREADY_USED_ERROR);
} else if (dataSource.updateEmail(auth)) {
auth.setEmail(email);
playerCache.updatePlayer(auth);
messages.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
} else {
messages.send(player, MessageKey.ERROR);
auth.setEmail(email);
if (dataSource.updateEmail(auth)) {
playerCache.updatePlayer(auth);
messages.send(player, MessageKey.EMAIL_ADDED_SUCCESS);
} else {
ConsoleLogger.showError("Could not save email for player '" + player + "'");
messages.send(player, MessageKey.ERROR);
}
}
} else {
sendUnloggedMessage(dataSource);

View File

@ -1,6 +1,7 @@
package fr.xephi.authme.process.email;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLoggerTestInitializer;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
@ -35,6 +36,7 @@ public class AsyncAddEmailTest {
@BeforeClass
public static void setUp() {
WrapperMock.createInstance();
ConsoleLoggerTestInitializer.setupLogger();
}
// Clean up the fields to ensure that no test uses elements of another test