mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-30 06:03:36 +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);
|
PlayerAuth pAuth = database.getAuth(name);
|
||||||
if (pAuth == null) {
|
if (pAuth == null) {
|
||||||
service.send(player, MessageKey.USER_NOT_REGISTERED);
|
service.send(player, MessageKey.USER_NOT_REGISTERED);
|
||||||
|
// Recreate the message task to immediately send the message again as response
|
||||||
// TODO ljacqu 20160612: Why is the message task being canceled and added again here?
|
// and to make sure we send the right register message (password vs. email registration)
|
||||||
playerDataTaskManager.registerMessageTask(name, false);
|
playerDataTaskManager.registerMessageTask(name, false);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -186,12 +186,8 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
} else if (player.isOnline()) {
|
} else if (player.isOnline()) {
|
||||||
ConsoleLogger.fine(player.getName() + " used the wrong password");
|
ConsoleLogger.fine(player.getName() + " used the wrong password");
|
||||||
if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) {
|
if (service.getProperty(RestrictionSettings.KICK_ON_WRONG_PASSWORD)) {
|
||||||
bukkitService.scheduleSyncDelayedTask(new Runnable() {
|
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(
|
||||||
@Override
|
() -> player.kickPlayer(service.retrieveSingleMessage(MessageKey.WRONG_PASSWORD)));
|
||||||
public void run() {
|
|
||||||
player.kickPlayer(service.retrieveSingleMessage(MessageKey.WRONG_PASSWORD));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (tempbanManager.shouldTempban(ip)) {
|
} else if (tempbanManager.shouldTempban(ip)) {
|
||||||
tempbanManager.tempbanPlayer(player);
|
tempbanManager.tempbanPlayer(player);
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,6 +15,7 @@ import fr.xephi.authme.security.PasswordSecurity;
|
|||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.security.crypts.TwoFactor;
|
import fr.xephi.authme.security.crypts.TwoFactor;
|
||||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
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.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
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 {
|
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
|
@Inject
|
||||||
private DataSource database;
|
private DataSource database;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PasswordSecurity passwordSecurity;
|
private PasswordSecurity passwordSecurity;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ProcessService service;
|
private ProcessService service;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SyncProcessManager syncProcessManager;
|
private SyncProcessManager syncProcessManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SendMailSSL sendMailSsl;
|
private SendMailSSL sendMailSsl;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AsynchronousLogin asynchronousLogin;
|
private AsynchronousLogin asynchronousLogin;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
|
|
||||||
|
|
||||||
AsyncRegister() {
|
AsyncRegister() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,7 +170,12 @@ public class AsyncRegister implements AsynchronousProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!service.getProperty(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER) && autoLogin) {
|
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);
|
syncProcessManager.processSyncPasswordRegister(player);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user