mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 19:41:59 -08:00
Add field for server console
This commit is contained in:
parent
6beb23dbb3
commit
fa97e4647e
11 changed files with 57 additions and 25 deletions
|
|
@ -132,7 +132,7 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean resetPassword(String sessionId, String email, String authToken, String password) throws MageException {
|
||||
if (!ConfigSettings.getInstance().isAuthenticationActivated()) {
|
||||
|
|
@ -158,13 +158,13 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean connectUser(String userName, String password, String sessionId, MageVersion version) throws MageException {
|
||||
public boolean connectUser(String userName, String password, String sessionId, MageVersion version, String userIdStr) throws MageException {
|
||||
try {
|
||||
if (version.compareTo(Main.getVersion()) != 0) {
|
||||
logger.info("MageVersionException: userName=" + userName + ", version=" + version);
|
||||
throw new MageVersionException(version, Main.getVersion());
|
||||
}
|
||||
return SessionManager.getInstance().connectUser(sessionId, userName, password);
|
||||
return SessionManager.getInstance().connectUser(sessionId, userName, password, userIdStr);
|
||||
} catch (MageException ex) {
|
||||
if (ex instanceof MageVersionException) {
|
||||
throw (MageVersionException) ex;
|
||||
|
|
@ -175,11 +175,11 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setUserData(final String userName, final String sessionId, final UserData userData, final String clientVersion) throws MageException {
|
||||
public boolean setUserData(final String userName, final String sessionId, final UserData userData, final String clientVersion, final String userIdStr) throws MageException {
|
||||
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
||||
@Override
|
||||
public Boolean execute() throws MageException {
|
||||
return SessionManager.getInstance().setUserData(userName, sessionId, userData, clientVersion);
|
||||
return SessionManager.getInstance().setUserData(userName, sessionId, userData, clientVersion, userIdStr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -943,7 +943,8 @@ public class MageServerImpl implements MageServer {
|
|||
user.getUserState().toString(),
|
||||
user.getChatLockedUntil(),
|
||||
user.getClientVersion(),
|
||||
user.getEmail()
|
||||
user.getEmail(),
|
||||
user.getUserIdStr()
|
||||
));
|
||||
}
|
||||
return users;
|
||||
|
|
|
|||
|
|
@ -264,12 +264,13 @@ public class Session {
|
|||
this.userId = user.getId();
|
||||
}
|
||||
|
||||
public boolean setUserData(String userName, UserData userData, String clientVersion) {
|
||||
public boolean setUserData(String userName, UserData userData, String clientVersion, String userIdStr) {
|
||||
User user = UserManager.getInstance().getUserByName(userName);
|
||||
if (user != null) {
|
||||
if (clientVersion != null) {
|
||||
user.setClientVersion(clientVersion);
|
||||
}
|
||||
user.setUserIdStr(userIdStr);
|
||||
if (user.getUserData() == null || user.getUserData().getGroupId() == UserGroup.DEFAULT.getGroupId()) {
|
||||
user.setUserData(userData);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class SessionManager {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean connectUser(String sessionId, String userName, String password) throws MageException {
|
||||
public boolean connectUser(String sessionId, String userName, String password, String userIdStr) throws MageException {
|
||||
Session session = sessions.get(sessionId);
|
||||
if (session != null) {
|
||||
String returnMessage = session.connectUser(userName, password);
|
||||
|
|
@ -117,10 +117,10 @@ public class SessionManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean setUserData(String userName, String sessionId, UserData userData, String clientVersion) throws MageException {
|
||||
public boolean setUserData(String userName, String sessionId, UserData userData, String clientVersion, String userIdStr) throws MageException {
|
||||
Session session = sessions.get(sessionId);
|
||||
if (session != null) {
|
||||
session.setUserData(userName, userData, clientVersion);
|
||||
session.setUserData(userName, userData, clientVersion, userIdStr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -217,7 +217,7 @@ public class SessionManager {
|
|||
if (session != null) {
|
||||
return UserManager.getInstance().getUser(sessions.get(sessionId).getUserId());
|
||||
}
|
||||
logger.error(String.format("Session %s could not be found",sessionId));
|
||||
logger.error(String.format("Session %s could not be found", sessionId));
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ public class User {
|
|||
private Date lockedUntil;
|
||||
private final AuthorizedUser authorizedUser;
|
||||
private String clientVersion;
|
||||
private String userIdStr;
|
||||
|
||||
public User(String userName, String host, AuthorizedUser authorizedUser) {
|
||||
this.userId = UUID.randomUUID();
|
||||
|
|
@ -127,6 +128,7 @@ public class User {
|
|||
this.tablesToDelete = new ArrayList<>();
|
||||
this.sessionId = "";
|
||||
this.clientVersion = "";
|
||||
this.userIdStr = "";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
@ -178,6 +180,14 @@ public class User {
|
|||
this.clientVersion = clientVersion;
|
||||
}
|
||||
|
||||
public void setUserIdStr(String userIdStr) {
|
||||
this.userIdStr = userIdStr;
|
||||
}
|
||||
|
||||
public String getUserIdStr() {
|
||||
return this.userIdStr;
|
||||
}
|
||||
|
||||
public String getClientVersion() {
|
||||
return clientVersion;
|
||||
}
|
||||
|
|
@ -199,7 +209,7 @@ public class User {
|
|||
|
||||
public void lostConnection() {
|
||||
// Because watched games don't get restored after reconnection call stop watching
|
||||
for (Iterator<UUID> iterator = watchedGames.iterator(); iterator.hasNext(); ) {
|
||||
for (Iterator<UUID> iterator = watchedGames.iterator(); iterator.hasNext();) {
|
||||
UUID gameId = iterator.next();
|
||||
GameManager.getInstance().stopWatching(gameId, userId);
|
||||
iterator.remove();
|
||||
|
|
@ -781,7 +791,7 @@ public class User {
|
|||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
public String getEmail() {
|
||||
if (authorizedUser != null) {
|
||||
return authorizedUser.email;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue