From 8dd1e21dba8a385beec0ef25411d06ab0cd22c3a Mon Sep 17 00:00:00 2001 From: Me Car Date: Mon, 11 Jan 2016 10:20:38 +0900 Subject: [PATCH] Exit early for less indentation. --- .../main/java/mage/server/SessionManager.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/SessionManager.java b/Mage.Server/src/main/java/mage/server/SessionManager.java index c0507f4b9b..63ef1ab914 100644 --- a/Mage.Server/src/main/java/mage/server/SessionManager.java +++ b/Mage.Server/src/main/java/mage/server/SessionManager.java @@ -72,23 +72,22 @@ public class SessionManager { public boolean registerUser(String sessionId, String userName, String password, String email) throws MageException { Session session = sessions.get(sessionId); - if (session != null) { - String returnMessage = session.registerUser(userName, password, email); - if (returnMessage == null) { - LogServiceImpl.instance.log(LogKeys.KEY_USER_REGISTERED, userName, session.getHost(), sessionId); - - logger.info(userName + " registered"); - logger.debug("- userId: " + session.getUserId()); - logger.debug("- sessionId: " + sessionId); - logger.debug("- host: " + session.getHost()); - return true; - } else { - logger.debug(userName + " not registered: " + returnMessage); - } - } else { + if (session == null) { logger.error(userName + " tried to register with no sessionId"); + return false; } - return false; + String returnMessage = session.registerUser(userName, password, email); + if (returnMessage != null) { + logger.debug(userName + " not registered: " + returnMessage); + return false; + } + LogServiceImpl.instance.log(LogKeys.KEY_USER_REGISTERED, userName, session.getHost(), sessionId); + + logger.info(userName + " registered"); + logger.debug("- userId: " + session.getUserId()); + logger.debug("- sessionId: " + sessionId); + logger.debug("- host: " + session.getHost()); + return true; } public boolean connectUser(String sessionId, String userName, String password) throws MageException {