diff --git a/lib/src/main/java/com/auth0/android/lock/views/LogInFormView.java b/lib/src/main/java/com/auth0/android/lock/views/LogInFormView.java index db6accdb6..21b96482e 100644 --- a/lib/src/main/java/com/auth0/android/lock/views/LogInFormView.java +++ b/lib/src/main/java/com/auth0/android/lock/views/LogInFormView.java @@ -180,41 +180,44 @@ public Object submitForm() { return null; } - if (currentConnection != null && currentConnection.isActiveFlowEnabled() && (passwordInput.getVisibility() == VISIBLE || singleConnection)) { - Log.d(TAG, String.format("Form submitted. Logging in with enterprise connection %s using active flow", currentConnection)); - return getActionEvent(); - } else if (currentConnection == null) { - Log.d(TAG, "Form submitted. Logging in with database connection using active flow"); + if (currentConnection == null || !currentConnection.isActiveFlowEnabled() || passwordInput.getVisibility() == VISIBLE || singleConnection) { return getActionEvent(); - } else { - Log.d(TAG, "Now showing SSO Login Form for connection " + currentConnection); - String loginWithCorporate = String.format(getResources().getString(R.string.com_auth0_lock_action_login_with_corporate), domainParser.domainForConnection(currentConnection)); - topMessage.setText(loginWithCorporate); - topMessage.setVisibility(View.VISIBLE); - emailInput.setVisibility(GONE); - passwordInput.setVisibility(View.VISIBLE); - usernameInput.setVisibility(VISIBLE); - if (currentUsername != null && !currentUsername.isEmpty()) { - usernameInput.setText(currentUsername); - } - changePasswordBtn.setVisibility(GONE); - corporateSSO = true; - usernameInput.clearFocus(); - InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN); } + + Log.d(TAG, "Now showing SSO Login Form for connection " + currentConnection); + String loginWithCorporate = String.format(getResources().getString(R.string.com_auth0_lock_action_login_with_corporate), domainParser.domainForConnection(currentConnection)); + topMessage.setText(loginWithCorporate); + topMessage.setVisibility(View.VISIBLE); + emailInput.setVisibility(GONE); + passwordInput.setVisibility(View.VISIBLE); + usernameInput.setVisibility(VISIBLE); + if (currentUsername != null && !currentUsername.isEmpty()) { + usernameInput.setText(currentUsername); + } + changePasswordBtn.setVisibility(GONE); + corporateSSO = true; + usernameInput.clearFocus(); + InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN); return null; } @Override public Object getActionEvent() { if (currentConnection != null && currentConnection.isActiveFlowEnabled()) { + Log.d(TAG, String.format("Form submitted. Logging in with enterprise connection %s using active flow", currentConnection)); return new EnterpriseLoginEvent(currentConnection.getName(), getUsername(), getPassword()); - } else if (currentConnection != null) { + } + if (currentConnection != null) { + Log.d(TAG, String.format("Form submitted. Logging in with enterprise connection %s using authorize screen", currentConnection)); return new EnterpriseLoginEvent(currentConnection.getName()); - } else { - return fallbackToDatabase ? new DatabaseLoginEvent(getUsername(), getPassword()) : new EnterpriseLoginEvent(null); } + if (fallbackToDatabase) { + Log.d(TAG, "Logging in with database connection using active flow"); + return new DatabaseLoginEvent(getUsername(), getPassword()); + } + //No domain for connection + return new EnterpriseLoginEvent(null); } @Override