Refactored post login logic in login controller

This commit is contained in:
Rohan Sircar 2020-05-26 21:50:46 +05:30
parent b7a24e6ca0
commit 748693a3a4

View File

@ -72,7 +72,7 @@ class LoginController @Inject() (
val inputPassword = passwordTextField.text() val inputPassword = passwordTextField.text()
submitButton.disable = true submitButton.disable = true
login(inputUserName, inputPassword) onComplete { login(inputUserName, inputPassword) andThen {
case Success(maybeToken) => { case Success(maybeToken) => {
maybeToken match { maybeToken match {
case Some(token) => case Some(token) =>
@ -82,12 +82,10 @@ class LoginController @Inject() (
appDataHandler.updateCredentials(credentials) appDataHandler.updateCredentials(credentials)
updateErrorLabel("") updateErrorLabel("")
applicationController.showChatPane() applicationController.showChatPane()
onFX { submitButton.disable = false }
} }
case None => { case None => {
updateErrorLabel("Error logging in - please check your password") updateErrorLabel("Error logging in - please check your password")
logger.warn("Login unsuccessful wrong password") logger.warn("Login unsuccessful wrong password")
onFX { submitButton.disable = false }
} }
} }
} }
@ -95,9 +93,11 @@ class LoginController @Inject() (
logger.error(s"${exception.getMessage()}") logger.error(s"${exception.getMessage()}")
logger.warn("Login unsuccessful network problem") logger.warn("Login unsuccessful network problem")
updateErrorLabel("Error logging in - Please check your network") updateErrorLabel("Error logging in - Please check your network")
onFX { submitButton.disable = false }
} }
} andThen {
case _ => { onFX { submitButton.disable = false } }
} }
} }
def updateErrorLabel(message: String) = onFX { def updateErrorLabel(message: String) = onFX {