mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08: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 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 toggleActivation(String sessionId, String userName) throws MageException;
|
||||||
|
|
||||||
void removeTable(String sessionId, UUID tableId) throws MageException;
|
void removeTable(String sessionId, UUID tableId) throws MageException;
|
||||||
|
|
|
||||||
|
|
@ -1467,6 +1467,24 @@ public class SessionImpl implements Session {
|
||||||
return false;
|
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
|
@Override
|
||||||
public boolean toggleActivation(String userName) {
|
public boolean toggleActivation(String userName) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@ public interface Connect {
|
||||||
|
|
||||||
boolean muteUserChat(String userName, long durationMinute);
|
boolean muteUserChat(String userName, long durationMinute);
|
||||||
|
|
||||||
|
boolean setActivation(String userName, boolean active);
|
||||||
|
|
||||||
boolean toggleActivation(String userName);
|
boolean toggleActivation(String userName);
|
||||||
|
|
||||||
boolean lockUser(String userName, long durationMinute);
|
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
|
@Override
|
||||||
public void toggleActivation(final String sessionId, final String userName) throws MageException {
|
public void toggleActivation(final String sessionId, final String userName) throws MageException {
|
||||||
execute("toggleActivation", sessionId, () -> {
|
execute("toggleActivation", sessionId, () -> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue