Skip to content

Commit

Permalink
fix #343 non ro-enabled enterprise connections flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
lbalmaceda committed Sep 15, 2016
1 parent fdf8d75 commit 9f71d9d
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions lib/src/main/java/com/auth0/android/lock/views/LogInFormView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9f71d9d

Please sign in to comment.