mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
spjspj - Add Set Active to server console
This commit is contained in:
parent
156a14a123
commit
6d3324378f
4 changed files with 36 additions and 0 deletions
|
@ -210,6 +210,8 @@ public interface MageServer {
|
|||
|
||||
void lockUser(String sessionId, String userName, long durationMinutes) throws MageException;
|
||||
|
||||
void setActivation(String sessionId, String userName, boolean active) throws MageException;
|
||||
|
||||
void toggleActivation(String sessionId, String userName) throws MageException;
|
||||
|
||||
void removeTable(String sessionId, UUID tableId) throws MageException;
|
||||
|
|
|
@ -1466,6 +1466,24 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setActivation(String userName, boolean active) {
|
||||
try {
|
||||
if (JOptionPane.showConfirmDialog(null, "Are you sure you mean to set active to " + active + " for user: " + userName + "?", "WARNING",
|
||||
JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
|
||||
if (isConnected()) {
|
||||
server.setActivation(sessionId, userName, active);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleActivation(String userName) {
|
||||
|
|
|
@ -58,6 +58,8 @@ public interface Connect {
|
|||
|
||||
boolean muteUserChat(String userName, long durationMinute);
|
||||
|
||||
boolean setActivation(String userName, boolean active);
|
||||
|
||||
boolean toggleActivation(String userName);
|
||||
|
||||
boolean lockUser(String userName, long durationMinute);
|
||||
|
|
|
@ -1008,6 +1008,20 @@ public class MageServerImpl implements MageServer {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActivation(final String sessionId, final String userName, boolean active) throws MageException {
|
||||
execute("setActivation", sessionId, () -> {
|
||||
User user = UserManager.getInstance().getUserByName(userName);
|
||||
if (user != null) {
|
||||
user.setActive(active);
|
||||
if (!user.isActive() && user.isConnected()) {
|
||||
SessionManager.getInstance().disconnectUser(sessionId, user.getSessionId());
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleActivation(final String sessionId, final String userName) throws MageException {
|
||||
execute("toggleActivation", sessionId, () -> {
|
||||
|
|
Loading…
Reference in a new issue