Add support for pasting authenticator code on login screen
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
@@ -54,6 +54,7 @@ public class LoginScreenPlugin extends Plugin implements KeyListener
|
|||||||
{
|
{
|
||||||
private static final int MAX_USERNAME_LENGTH = 254;
|
private static final int MAX_USERNAME_LENGTH = 254;
|
||||||
private static final int MAX_PASSWORD_LENGTH = 20;
|
private static final int MAX_PASSWORD_LENGTH = 20;
|
||||||
|
private static final int MAX_PIN_LENGTH = 6;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
@@ -163,7 +164,9 @@ public class LoginScreenPlugin extends Plugin implements KeyListener
|
|||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent e)
|
public void keyPressed(KeyEvent e)
|
||||||
{
|
{
|
||||||
if (!config.pasteEnabled() || client.getGameState() != GameState.LOGIN_SCREEN)
|
if (!config.pasteEnabled() || (
|
||||||
|
client.getGameState() != GameState.LOGIN_SCREEN &&
|
||||||
|
client.getGameState() != GameState.LOGIN_SCREEN_AUTHENTICATOR))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -182,16 +185,27 @@ public class LoginScreenPlugin extends Plugin implements KeyListener
|
|||||||
.toString()
|
.toString()
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
// 0 is username, 1 is password
|
switch (client.getLoginIndex())
|
||||||
if (client.getCurrentLoginField() == 0)
|
|
||||||
{
|
{
|
||||||
// Truncate data to maximum username length if necessary
|
// Username/password form
|
||||||
client.setUsername(data.substring(0, Math.min(data.length(), MAX_USERNAME_LENGTH)));
|
case 2:
|
||||||
}
|
if (client.getCurrentLoginField() == 0)
|
||||||
else
|
{
|
||||||
{
|
// Truncate data to maximum username length if necessary
|
||||||
// Truncate data to maximum password length if necessary
|
client.setUsername(data.substring(0, Math.min(data.length(), MAX_USERNAME_LENGTH)));
|
||||||
client.setPassword(data.substring(0, Math.min(data.length(), MAX_PASSWORD_LENGTH)));
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Truncate data to maximum password length if necessary
|
||||||
|
client.setPassword(data.substring(0, Math.min(data.length(), MAX_PASSWORD_LENGTH)));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
// Authenticator form
|
||||||
|
case 4:
|
||||||
|
// Truncate data to maximum OTP code length if necessary
|
||||||
|
client.setOtp(data.substring(0, Math.min(data.length(), MAX_PIN_LENGTH)));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (UnsupportedFlavorException | IOException ex)
|
catch (UnsupportedFlavorException | IOException ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user