Skip to content

Commit 9782793

Browse files
committed
Cleanup
1 parent f06845b commit 9782793

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

auth/src/main/java/com/firebase/ui/auth/util/smartlock/SignInDelegate.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ public void onCancel(DialogInterface dialogInterface) {
9696
return;
9797
}
9898

99-
if (!mFlowParams.smartLockEnabled) {
100-
startAuthMethodChoice();
101-
} else {
99+
if (mFlowParams.smartLockEnabled) {
102100
showProgress();
103101
initGoogleApiClient(null);
104102
Auth.CredentialsApi
@@ -108,6 +106,8 @@ public void onCancel(DialogInterface dialogInterface) {
108106
.setAccountTypes(IdentityProviders.GOOGLE)
109107
.build())
110108
.setResultCallback(this);
109+
} else {
110+
startAuthMethodChoice();
111111
}
112112
}
113113

@@ -119,31 +119,29 @@ public void onResult(@NonNull CredentialRequestResult result) {
119119
if (status.isSuccess()) {
120120
// Auto sign-in success
121121
handleCredential(result.getCredential());
122-
delegateSignIn(true, false);
122+
delegateSignIn(true);
123123
} else if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
124-
delegateSignIn(false, true);
124+
delegateSignIn(false);
125125
}
126126
}
127127

128-
private void delegateSignIn(boolean isAutoSignInAvailable, boolean isSignInResolutionNeeded) {
128+
private void delegateSignIn(boolean isAutoSignInAvailable) {
129129
String email = getEmailFromCredential();
130130
String password = getPasswordFromCredential();
131131

132132
// Attempt auto-sign in using SmartLock
133133
if (isAutoSignInAvailable) {
134134
googleSilentSignIn();
135-
if (!TextUtils.isEmpty(password)) {
136-
// Sign in with the email/password retrieved from SmartLock
137-
signInWithEmailAndPassword(email, password);
138-
} else {
135+
if (TextUtils.isEmpty(password)) {
139136
// log in with id/provider
140137
redirectToIdpSignIn(email, getAccountTypeFromCredential());
138+
} else {
139+
// Sign in with the email/password retrieved from SmartLock
140+
signInWithEmailAndPassword(email, password);
141141
}
142-
} else if (isSignInResolutionNeeded) {
142+
} else {
143143
// resolve credential
144144
resolveSavedEmails();
145-
} else {
146-
startAuthMethodChoice();
147145
}
148146
hideProgress();
149147
}
@@ -169,12 +167,12 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
169167
String email = getEmailFromCredential();
170168
String password = getPasswordFromCredential();
171169
if (email != null) {
172-
if (password != null && !password.isEmpty()) {
173-
// email/password combination
174-
signInWithEmailAndPassword(email, password);
175-
} else {
170+
if (password == null || password.isEmpty()) {
176171
// identifier/provider combination
177172
redirectToIdpSignIn(email, getAccountTypeFromCredential());
173+
} else {
174+
// email/password combination
175+
signInWithEmailAndPassword(email, password);
178176
}
179177
}
180178
} else if (resultCode == RESULT_CANCELED

0 commit comments

Comments
 (0)