mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 04:35:12 +01:00
#937 Fix auto login after register not working in sync mode
- Need a small delay to allow the database to store the PlayerAuth object in the registration process
This commit is contained in:
parent
4eab258993
commit
f688eb4574
@ -89,8 +89,8 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
PlayerAuth pAuth = database.getAuth(name);
|
||||
if (pAuth == null) {
|
||||
service.send(player, MessageKey.USER_NOT_REGISTERED);
|
||||
|
||||
// TODO ljacqu 20160612: Why is the message task being canceled and added again here?
|
||||
// Recreate the message task to immediately send the message again as response
|
||||
// and to make sure we send the right register message (password vs. email registration)
|
||||
playerDataTaskManager.registerMessageTask(name, false);
|
||||
return null;
|
||||
}
|
||||
@ -186,12 +186,8 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
} else if (player.isOnline()) {
|
||||
ConsoleLogger.fine(player.getName() + " used the wrong password");
|
||||
if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) {
|
||||
bukkitService.scheduleSyncDelayedTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.kickPlayer(service.retrieveSingleMessage(MessageKey.WRONG_PASSWORD));
|
||||
}
|
||||
});
|
||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(
|
||||
() -> player.kickPlayer(service.retrieveSingleMessage(MessageKey.WRONG_PASSWORD)));
|
||||
} else if (tempbanManager.shouldTempban(ip)) {
|
||||
tempbanManager.tempbanPlayer(player);
|
||||
} else {
|
||||
|
@ -15,6 +15,7 @@ import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.security.crypts.TwoFactor;
|
||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
@ -36,37 +37,34 @@ import static fr.xephi.authme.permission.PlayerStatePermission.ALLOW_MULTIPLE_AC
|
||||
*/
|
||||
public class AsyncRegister implements AsynchronousProcess {
|
||||
|
||||
/**
|
||||
* Number of ticks to wait before running the login action when it is run synchronously.
|
||||
* A small delay is necessary or the database won't return the newly saved PlayerAuth object
|
||||
* and the login process thinks the user is not registered.
|
||||
*/
|
||||
private static final int SYNC_LOGIN_DELAY = 5;
|
||||
|
||||
@Inject
|
||||
private DataSource database;
|
||||
|
||||
@Inject
|
||||
private PlayerCache playerCache;
|
||||
|
||||
@Inject
|
||||
private PasswordSecurity passwordSecurity;
|
||||
|
||||
@Inject
|
||||
private ProcessService service;
|
||||
|
||||
@Inject
|
||||
private SyncProcessManager syncProcessManager;
|
||||
|
||||
@Inject
|
||||
private PermissionsManager permissionsManager;
|
||||
|
||||
@Inject
|
||||
private ValidationService validationService;
|
||||
|
||||
@Inject
|
||||
private SendMailSSL sendMailSsl;
|
||||
|
||||
@Inject
|
||||
private AsynchronousLogin asynchronousLogin;
|
||||
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
|
||||
AsyncRegister() {
|
||||
}
|
||||
|
||||
@ -172,7 +170,12 @@ public class AsyncRegister implements AsynchronousProcess {
|
||||
}
|
||||
|
||||
if (!service.getProperty(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER) && autoLogin) {
|
||||
bukkitService.runTaskOptionallyAsync(() -> asynchronousLogin.login(player, "dontneed", true));
|
||||
if (service.getProperty(PluginSettings.USE_ASYNC_TASKS)) {
|
||||
bukkitService.runTaskAsynchronously(() -> asynchronousLogin.login(player, "dontneed", true));
|
||||
} else {
|
||||
bukkitService.scheduleSyncDelayedTask(
|
||||
() -> asynchronousLogin.login(player, "dontneed", true), SYNC_LOGIN_DELAY);
|
||||
}
|
||||
}
|
||||
syncProcessManager.processSyncPasswordRegister(player);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user