Skip to content

Commit

Permalink
Hotfix: Fixed register and login crashing from empty input
Browse files Browse the repository at this point in the history
  • Loading branch information
wwongandy committed Jan 5, 2020
1 parent 7d40cd7 commit f0d2346
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ class AuthenticationPresenter(view: BaseView): BasePresenter(view) {
view?.showProgress()
auth.createUserWithEmailAndPassword(username, password).addOnCompleteListener(view!!) { task ->
if (task.isSuccessful) {
view?.navigateTo(VIEW.HILLFORTLIST)
if (fireStore != null) {
fireStore!!.fetchHillforts {
view?.hideProgress()
view?.navigateTo(VIEW.HILLFORTLIST)
}
} else {
view?.hideProgress()
view?.navigateTo(VIEW.HILLFORTLIST)
}
} else {
view?.toast("Sign Up Failed: ${task.exception?.message}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ class AuthenticationView: BaseView(), AnkoLogger {
val _username = username.text.toString()
val _password = password.text.toString()

presenter.doRegisterUser(_username, _password)
if (_username.isNotEmpty() && _password.isNotEmpty()) {
presenter.doRegisterUser(_username, _password)
} else {
toast("You cannot leave a field empty!")
}
}

loginUser.setOnClickListener {
presenter.doLoginUser(username.text.toString(), password.text.toString())
val _username = username.text.toString()
val _password = password.text.toString()

if (_username.isNotEmpty() && _password.isNotEmpty()) {
presenter.doLoginUser(_username, _password)
} else {
toast("You cannot leave a field empty!")
}
}

progressBar.visibility = View.GONE
Expand Down

0 comments on commit f0d2346

Please sign in to comment.