-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Auth code cleanup #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth code cleanup #376
Changes from 8 commits
6ecc551
00a59cd
bb352e9
d8f1e1a
e733913
9ab7dd4
b5fe9f1
7a05e46
51dc270
90f2c56
1234066
575cb9b
34a7800
5e7c955
97bc852
41c5ddd
e666a15
6798d92
afd6fc9
1cdf4f2
2b2da92
9d9b7f5
47b204e
6e35dcb
18e969f
a183c7f
26343b4
2ac59d9
8925f51
9603d9a
2e9f399
f60c448
0406cd8
0c85d63
7b95605
5610ad1
af34fab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,22 +29,22 @@ android { | |
} | ||
} | ||
|
||
|
||
dependencies { | ||
testCompile 'junit:junit:4.12' | ||
testCompile 'org.mockito:mockito-core:2.2.0' | ||
testCompile 'org.robolectric:robolectric:3.1.2' | ||
// See https://github.com/robolectric/robolectric/issues/1932#issuecomment-219796474 | ||
testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1' | ||
|
||
compile 'com.facebook.android:facebook-android-sdk:4.14.1' | ||
compile("com.twitter.sdk.android:twitter:2.0.0@aar") { | ||
transitive = true; | ||
} | ||
compile "com.android.support:design:${project.ext.support_library_version}" | ||
|
||
compile "com.google.firebase:firebase-auth:${project.ext.firebase_version}" | ||
compile "com.google.android.gms:play-services-auth:${project.ext.firebase_version}" | ||
|
||
compile 'com.facebook.android:facebook-android-sdk:4.16.1' | ||
compile("com.twitter.sdk.android:twitter:2.1.1@aar") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. old: 2.0.0 |
||
transitive = true | ||
} | ||
|
||
testCompile 'junit:junit:4.12' | ||
testCompile 'org.mockito:mockito-core:2.2.6' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. old: 2.2.0 |
||
testCompile 'org.robolectric:robolectric:3.1.2' | ||
// See https://github.com/robolectric/robolectric/issues/1932#issuecomment-219796474 | ||
testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1' | ||
} | ||
|
||
checkstyle { | ||
|
@@ -64,8 +64,8 @@ javadoc.exclude([ | |
'com/firebase/ui/auth/ui/ExtraConstants', | ||
'com/firebase/ui/auth/ui/email/field_validators/**', | ||
'com/firebase/ui/auth/util/**', | ||
]) | ||
]) | ||
|
||
javadoc.include([ | ||
'com/google/firebase/auth/**' | ||
]) | ||
]) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,10 @@ | |
|
||
public class AcquireEmailHelper { | ||
private static final String TAG = "AcquireEmailHelper"; | ||
public static final int RC_REGISTER_ACCOUNT = 14; | ||
public static final int RC_WELCOME_BACK_IDP = 15; | ||
private static final int RC_REGISTER_ACCOUNT = 14; | ||
private static final int RC_WELCOME_BACK_IDP = 15; | ||
public static final int RC_SIGN_IN = 16; | ||
public static final List<Integer> REQUEST_CODES = Arrays.asList( | ||
private static final List<Integer> REQUEST_CODES = Arrays.asList( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was there a reason for keeping this stuff public? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope this LGTM, not meant to be part of the public API/ |
||
RC_REGISTER_ACCOUNT, | ||
RC_WELCOME_BACK_IDP, | ||
RC_SIGN_IN | ||
|
@@ -80,30 +80,22 @@ private void startEmailHandler(String email, List<String> providers) { | |
mActivityHelper.startActivityForResult(registerIntent, RC_REGISTER_ACCOUNT); | ||
} else { | ||
// account does exist | ||
for (String provider : providers) { | ||
if (provider.equalsIgnoreCase(EmailAuthProvider.PROVIDER_ID)) { | ||
Intent signInIntent = SignInActivity.createIntent( | ||
mActivityHelper.getApplicationContext(), | ||
mActivityHelper.getFlowParams(), | ||
email); | ||
mActivityHelper.startActivityForResult(signInIntent, RC_SIGN_IN); | ||
return; | ||
} | ||
|
||
Intent intent = WelcomeBackIdpPrompt.createIntent( | ||
if (providers.get(0).equalsIgnoreCase(EmailAuthProvider.PROVIDER_ID)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the most important change in this PR: the for loop doesn't loop! Is my change appropriate or should we be doing something else here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we be sure that if the email provider is in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Intent signInIntent = SignInActivity.createIntent( | ||
mActivityHelper.getApplicationContext(), | ||
mActivityHelper.getFlowParams(), | ||
provider, | ||
null, | ||
email); | ||
mActivityHelper.startActivityForResult(intent, RC_WELCOME_BACK_IDP); | ||
mActivityHelper.startActivityForResult(signInIntent, RC_SIGN_IN); | ||
return; | ||
} | ||
|
||
Intent signInIntent = new Intent( | ||
mActivityHelper.getApplicationContext(), SignInActivity.class); | ||
signInIntent.putExtra(ExtraConstants.EXTRA_EMAIL, email); | ||
mActivityHelper.startActivityForResult(signInIntent, RC_SIGN_IN); | ||
Intent intent = WelcomeBackIdpPrompt.createIntent( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be a behavior change from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
mActivityHelper.getApplicationContext(), | ||
mActivityHelper.getFlowParams(), | ||
providers.get(0), | ||
null, | ||
email); | ||
mActivityHelper.startActivityForResult(intent, RC_WELCOME_BACK_IDP); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
import android.app.Activity; | ||
import android.app.PendingIntent; | ||
import android.support.annotation.NonNull; | ||
|
||
import com.firebase.ui.auth.AuthUI; | ||
import com.firebase.ui.auth.AuthUI.IdpConfig; | ||
import com.google.android.gms.auth.api.Auth; | ||
|
@@ -32,6 +33,7 @@ | |
import com.google.android.gms.tasks.Continuation; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.android.gms.tasks.TaskCompletionSource; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
@@ -76,8 +78,7 @@ public Task<CredentialRequestResult> request(final CredentialRequest request) { | |
@Override | ||
protected void process( | ||
final GoogleApiClient client, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed all the throws exception here. Did they serve a purpose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess not? @amandle see anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why these are throwing Exception, @iainmcgin might know |
||
final TaskCompletionSource<CredentialRequestResult> source) | ||
throws Exception { | ||
final TaskCompletionSource<CredentialRequestResult> source) { | ||
Auth.CredentialsApi.request(client, request) | ||
.setResultCallback(new TaskResultCaptor<>(source)); | ||
} | ||
|
@@ -90,10 +91,9 @@ public Task<Status> save(final Credential credential) { | |
@Override | ||
protected void process( | ||
GoogleApiClient client, | ||
TaskCompletionSource<Status> source) | ||
throws Exception { | ||
TaskCompletionSource<Status> source) { | ||
Auth.CredentialsApi.save(client, credential) | ||
.setResultCallback(new TaskResultCaptor<Status>(source)); | ||
.setResultCallback(new TaskResultCaptor<>(source)); | ||
} | ||
}); | ||
} | ||
|
@@ -104,8 +104,7 @@ public Task<PendingIntent> getHintPickerIntent(final HintRequest request) { | |
@Override | ||
protected void process( | ||
GoogleApiClient client, | ||
TaskCompletionSource<PendingIntent> source) | ||
throws Exception { | ||
TaskCompletionSource<PendingIntent> source) { | ||
source.setResult(Auth.CredentialsApi.getHintPickerIntent(client, request)); | ||
} | ||
}); | ||
|
@@ -117,9 +116,9 @@ public Task<Status> delete(final Credential credential) { | |
@Override | ||
protected void process( | ||
GoogleApiClient client, | ||
TaskCompletionSource<Status> source) throws Exception { | ||
TaskCompletionSource<Status> source) { | ||
Auth.CredentialsApi.delete(client, credential) | ||
.setResultCallback(new TaskResultCaptor<Status>(source)); | ||
.setResultCallback(new TaskResultCaptor<>(source)); | ||
} | ||
}); | ||
} | ||
|
@@ -130,8 +129,7 @@ public Task<Status> disableAutoSignIn() { | |
@Override | ||
protected void process( | ||
final GoogleApiClient client, | ||
final TaskCompletionSource<Status> source) | ||
throws Exception { | ||
final TaskCompletionSource<Status> source) { | ||
Auth.CredentialsApi.disableAutoSignIn(client) | ||
.setResultCallback(new ResultCallback<Status>() { | ||
@Override | ||
|
@@ -169,7 +167,7 @@ public final Task<OutT> then(@NonNull Task<InT> task) throws Exception { | |
return source.getTask(); | ||
} | ||
|
||
protected abstract void process(InT in, TaskCompletionSource<OutT> result) throws Exception; | ||
protected abstract void process(InT in, TaskCompletionSource<OutT> result); | ||
} | ||
|
||
private static final class TaskResultCaptor<R extends Result> implements ResultCallback<R> { | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old: v4.14.1