No duplicate login's like auth plugins auto logins if it's the same ip

This commit is contained in:
games647
2016-09-23 10:42:25 +02:00
parent bebb04bdea
commit ae3e03405d
7 changed files with 29 additions and 3 deletions

View File

@ -2,6 +2,7 @@
* Remove deprecated API methods from the last version
* Finally set a value to the API column
* No duplicate session login
######1.9

View File

@ -28,8 +28,10 @@ public class AuthMeHook implements AuthPlugin<Player> {
public boolean forceLogin(Player player) {
//skips registration and login
if (isNewAPIAvailable) {
NewAPI.getInstance().forceLogin(player);
} else {
if (!NewAPI.getInstance().isAuthenticated(player)) {
NewAPI.getInstance().forceLogin(player);
}
} else if (!API.isAuthenticated(player)) {
API.forceLogin(player);
}
@ -50,6 +52,7 @@ public class AuthMeHook implements AuthPlugin<Player> {
@SuppressWarnings("deprecation")
public boolean forceRegister(Player player, String password) {
if (isNewAPIAvailable) {
//this automatically registers the player too
NewAPI.getInstance().forceRegister(player, password);
} else {
API.registerPlayer(player.getName(), password);

View File

@ -5,6 +5,7 @@ import com.github.games647.fastlogin.core.hooks.AuthPlugin;
import io.github.lucaseasedup.logit.CancelledState;
import io.github.lucaseasedup.logit.LogItCore;
import io.github.lucaseasedup.logit.account.Account;
import io.github.lucaseasedup.logit.session.SessionManager;
import org.bukkit.entity.Player;
@ -19,7 +20,12 @@ public class LogItHook implements AuthPlugin<Player> {
@Override
public boolean forceLogin(Player player) {
return LogItCore.getInstance().getSessionManager().startSession(player) == CancelledState.NOT_CANCELLED;
SessionManager sessionManager = LogItCore.getInstance().getSessionManager();
if (sessionManager.isSessionAlive(player)) {
return true;
}
return sessionManager.startSession(player) == CancelledState.NOT_CANCELLED;
}
@Override

View File

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

View File

@ -28,6 +28,10 @@ public class RoyalAuthHook implements AuthPlugin<Player> {
AuthPlayer authPlayer = AuthPlayer.getAuthPlayer(player);
Future<Boolean> future = Bukkit.getScheduler().callSyncMethod(royalAuthPlugin, () -> {
if (authPlayer.isLoggedIn()) {
return true;
}
//https://github.com/RoyalDev/RoyalAuth/blob/master/src/main/java/org/royaldev/royalauth/commands/CmdLogin.java#L62
//not thread-safe
authPlayer.login();

View File

@ -28,6 +28,10 @@ public class UltraAuthHook implements AuthPlugin<Player> {
public boolean forceLogin(Player player) {
//not thread-safe
Future<Boolean> future = Bukkit.getScheduler().callSyncMethod(ultraAuthPlugin, () -> {
if (UltraAuthAPI.isAuthenticated(player)) {
return true;
}
UltraAuthAPI.authenticatedPlayer(player);
return UltraAuthAPI.isAuthenticated(player);
});

View File

@ -30,6 +30,10 @@ public class xAuthHook implements AuthPlugin<Player> {
Future<Boolean> future = Bukkit.getScheduler().callSyncMethod(xAuthPlugin, () -> {
xAuthPlayer xAuthPlayer = xAuthPlugin.getPlayerManager().getPlayer(player);
if (xAuthPlayer != null) {
if (xAuthPlayer.isAuthenticated()) {
return true;
}
//we checked that the player is premium (paid account)
xAuthPlayer.setPremium(true);