Warn if FastLogin doesn't login authenticated players

Related #351
This commit is contained in:
games647
2020-05-15 14:38:22 +02:00
parent b9cf8f0498
commit feee64309e
6 changed files with 24 additions and 4 deletions

View File

@ -42,6 +42,7 @@ public class AuthMeHook implements AuthPlugin<Player>, Listener {
@Override
public boolean forceLogin(Player player) {
if (AuthMeApi.getInstance().isAuthenticated(player)) {
plugin.getLog().warn(ALREADY_AUTHENTICATED, player);
return false;
}

View File

@ -1,5 +1,6 @@
package com.github.games647.fastlogin.bukkit.hook;
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import io.github.lucaseasedup.logit.CancelledState;
@ -22,11 +23,21 @@ import org.bukkit.entity.Player;
*/
public class LogItHook implements AuthPlugin<Player> {
private final FastLoginBukkit plugin;
public LogItHook(FastLoginBukkit plugin) {
this.plugin = plugin;
}
@Override
public boolean forceLogin(Player player) {
SessionManager sessionManager = LogItCore.getInstance().getSessionManager();
return sessionManager.isSessionAlive(player)
|| sessionManager.startSession(player) == CancelledState.NOT_CANCELLED;
if (sessionManager.isSessionAlive(player)) {
plugin.getLog().warn(ALREADY_AUTHENTICATED, player);
return false;
}
return sessionManager.startSession(player) == CancelledState.NOT_CANCELLED;
}
@Override

View File

@ -30,6 +30,11 @@ public class LoginSecurityHook implements AuthPlugin<Player> {
@Override
public boolean forceLogin(Player player) {
PlayerSession session = LoginSecurity.getSessionManager().getPlayerSession(player);
if (session.isAuthorized()) {
plugin.getLog().warn(ALREADY_AUTHENTICATED, player);
return true;
}
return session.isAuthorized()
|| session.performAction(new LoginAction(AuthService.PLUGIN, plugin)).isSuccess();
}

View File

@ -34,7 +34,7 @@ public class UltraAuthHook implements AuthPlugin<Player> {
//not thread-safe
Future<Boolean> future = Bukkit.getScheduler().callSyncMethod(plugin, () -> {
if (UltraAuthAPI.isAuthenticated(player)) {
return true;
return false;
}
UltraAuthAPI.authenticatedPlayer(player);

View File

@ -35,7 +35,8 @@ public class xAuthHook implements AuthPlugin<Player> {
xAuthPlayer xAuthPlayer = xAuthPlugin.getPlayerManager().getPlayer(player);
if (xAuthPlayer != null) {
if (xAuthPlayer.isAuthenticated()) {
return true;
plugin.getLog().warn("Player {} is already authenticated", player);
return false;
}
//we checked that the player is premium (paid account)

View File

@ -8,6 +8,8 @@ package com.github.games647.fastlogin.core.hooks;
*/
public interface AuthPlugin<P> {
String ALREADY_AUTHENTICATED = "Player {} is already authenticated. Cancelling force login.";
/**
* Login the premium (paid account) player after the player joined successfully the server.
*