mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-24 09:37:42 +01:00
Start working on #687
Next step: Future return of the async registration
This commit is contained in:
parent
552ecb5d8e
commit
1ea2f98727
@ -148,10 +148,11 @@ public class NewAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a player with the given password.
|
||||
* Register an OFFLINE/ONLINE player with the given password.
|
||||
*
|
||||
* @param playerName The player to register
|
||||
* @param password The password to register the player with
|
||||
*
|
||||
* @return true if the player was registered successfully
|
||||
*/
|
||||
public boolean registerPlayer(String playerName, String password) {
|
||||
@ -187,13 +188,24 @@ public class NewAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a player with the given password.
|
||||
* Force an ONLINE player to register.
|
||||
*
|
||||
* @param player The player to register
|
||||
* @param password The password to use
|
||||
* @param autoLogin Should the player be authenticated automatically after the registration?
|
||||
*/
|
||||
public void forceRegister(Player player, String password, boolean autoLogin) {
|
||||
plugin.getManagement().performRegister(player, password, null, autoLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an ONLINE player with the given password.
|
||||
*
|
||||
* @param player The player to register
|
||||
* @param password The password to use
|
||||
*/
|
||||
public void forceRegister(Player player, String password) {
|
||||
plugin.getManagement().performRegister(player, password, null);
|
||||
forceRegister(player, password, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ public class RegisterCommand extends PlayerCommand {
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
if (commandService.getProperty(SecuritySettings.PASSWORD_HASH) == HashAlgorithm.TWO_FACTOR) {
|
||||
//for two factor auth we don't need to check the usage
|
||||
commandService.getManagement().performRegister(player, "", "");
|
||||
commandService.getManagement().performRegister(player, "", "", true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ public class RegisterCommand extends PlayerCommand {
|
||||
if (commandService.getProperty(ENABLE_PASSWORD_CONFIRMATION) && !arguments.get(0).equals(arguments.get(1))) {
|
||||
commandService.send(player, MessageKey.PASSWORD_MATCH_ERROR);
|
||||
} else {
|
||||
commandService.getManagement().performRegister(player, arguments.get(0), "");
|
||||
commandService.getManagement().performRegister(player, arguments.get(0), "", true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class RegisterCommand extends PlayerCommand {
|
||||
commandService.send(player, MessageKey.USAGE_REGISTER);
|
||||
} else {
|
||||
String thePass = RandomString.generate(commandService.getProperty(RECOVERY_PASSWORD_LENGTH));
|
||||
commandService.getManagement().performRegister(player, thePass, email);
|
||||
commandService.getManagement().performRegister(player, thePass, email, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ public class Management {
|
||||
runTask(new AsynchronousLogout(player, plugin, dataSource, processService));
|
||||
}
|
||||
|
||||
public void performRegister(final Player player, final String password, final String email) {
|
||||
runTask(new AsyncRegister(player, password, email, plugin, dataSource, playerCache, processService));
|
||||
public void performRegister(final Player player, final String password, final String email, final boolean autoLogin) {
|
||||
runTask(new AsyncRegister(player, password, email, plugin, dataSource, playerCache, processService, autoLogin));
|
||||
}
|
||||
|
||||
public void performUnregister(final Player player, final String password, final boolean force) {
|
||||
|
@ -37,9 +37,10 @@ public class AsyncRegister implements Process {
|
||||
private final DataSource database;
|
||||
private final PlayerCache playerCache;
|
||||
private final ProcessService service;
|
||||
private final boolean autoLogin;
|
||||
|
||||
public AsyncRegister(Player player, String password, String email, AuthMe plugin, DataSource data,
|
||||
PlayerCache playerCache, ProcessService service) {
|
||||
PlayerCache playerCache, ProcessService service, boolean autoLogin) {
|
||||
this.player = player;
|
||||
this.password = password;
|
||||
this.name = player.getName().toLowerCase();
|
||||
@ -49,6 +50,7 @@ public class AsyncRegister implements Process {
|
||||
this.ip = Utils.getPlayerIp(player);
|
||||
this.playerCache = playerCache;
|
||||
this.service = service;
|
||||
this.autoLogin = autoLogin;
|
||||
}
|
||||
|
||||
private boolean preRegisterCheck() {
|
||||
@ -150,7 +152,7 @@ public class AsyncRegister implements Process {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Settings.forceRegLogin) {
|
||||
if (!Settings.forceRegLogin && autoLogin) {
|
||||
//PlayerCache.getInstance().addPlayer(auth);
|
||||
//database.setLogged(name);
|
||||
// TODO: check this...
|
||||
|
@ -84,7 +84,7 @@ public class RegisterCommandTest {
|
||||
command.executeCommand(sender, Collections.<String>emptyList(), commandService);
|
||||
|
||||
// then
|
||||
verify(management).performRegister(sender, "", "");
|
||||
verify(management).performRegister(sender, "", "", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -204,7 +204,7 @@ public class RegisterCommandTest {
|
||||
|
||||
// then
|
||||
verify(commandService).validateEmail(playerMail);
|
||||
verify(management).performRegister(eq(sender), argThat(stringWithLength(passLength)), eq(playerMail));
|
||||
verify(management).performRegister(eq(sender), argThat(stringWithLength(passLength)), eq(playerMail), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -230,7 +230,7 @@ public class RegisterCommandTest {
|
||||
command.executeCommand(sender, Collections.singletonList("myPass"), commandService);
|
||||
|
||||
// then
|
||||
verify(management).performRegister(sender, "myPass", "");
|
||||
verify(management).performRegister(sender, "myPass", "", true);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user