Skip to content

Redo changes from #591 #630

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

Merged
merged 25 commits into from
Mar 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e2aa484
reauthentication wip
Feb 7, 2017
4e6bd2a
clean up some lint errors
Feb 9, 2017
096c666
Review feedback part 1
Feb 10, 2017
4b5c4f8
Review feedback part 2
Feb 16, 2017
ab4a995
Use the native cancel string
Feb 16, 2017
50245ab
fix smartlock disabling in reauth
Feb 17, 2017
4815e33
Merge branch 'version-1.2.0-dev' into reauthenticate
Feb 17, 2017
3b58af0
Merge remote-tracking branch 'firebase/version-2.0.0-dev' into reauth…
SUPERCILEX Feb 24, 2017
7223256
Cleanup
SUPERCILEX Feb 24, 2017
d764d3e
Fix broken tests
SUPERCILEX Feb 24, 2017
e3e4d41
Merge remote-tracking branch 'firebase/version-2.0.0-dev' into reauth…
SUPERCILEX Feb 24, 2017
6ca1054
reauthentication wip
Feb 7, 2017
aed0c47
clean up some lint errors
Feb 9, 2017
316a62f
Review feedback part 1
Feb 10, 2017
6f68e7a
Review feedback part 2
Feb 16, 2017
463fdf3
Use the native cancel string
Feb 16, 2017
10d65c2
fix smartlock disabling in reauth
Feb 17, 2017
46704e9
Merge remote-tracking branch 'firebase/version-2.0.0-dev' into fix-re…
SUPERCILEX Mar 6, 2017
422db3a
Merge remote-tracking branch 'tmp/reauthenticate' into fix-reauth-pr
SUPERCILEX Mar 6, 2017
dab9bbd
show toast when logging in with a specific Google account
Mar 10, 2017
0ea20ee
skip smart lock for non-password reauths
Mar 10, 2017
f158048
Merge remote-tracking branch 'firebase/version-2.0.0-dev' into fix-re…
SUPERCILEX Mar 13, 2017
0e16a9e
Merge branch 'reauthenticate' of https://github.com/amandle/FirebaseU…
SUPERCILEX Mar 13, 2017
ece96e5
Merge remote-tracking branch 'firebase/version-2.0.0-dev' into fix-re…
SUPERCILEX Mar 13, 2017
e2c63f8
Cleanup
SUPERCILEX Mar 13, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions app/src/main/java/com/firebase/uidemo/auth/SignedInActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import java.util.List;

public class SignedInActivity extends AppCompatActivity {
private static final String EXTRA_SIGNED_IN_CONFIG = "extra_signed_in_config";
Expand Down Expand Up @@ -241,12 +241,11 @@ static final class SignedInConfig implements Parcelable {
String tosUrl;
boolean isSmartLockEnabled;

SignedInConfig(
int logo,
int theme,
List<IdpConfig> providerInfo,
String tosUrl,
boolean isSmartLockEnabled) {
SignedInConfig(int logo,
int theme,
List<IdpConfig> providerInfo,
String tosUrl,
boolean isSmartLockEnabled) {
this.logo = logo;
this.theme = theme;
this.providerInfo = providerInfo;
Expand Down
37 changes: 16 additions & 21 deletions auth/src/main/java/com/firebase/ui/auth/AuthUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import android.content.Intent;
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.CallSuper;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.StyleRes;
import android.support.annotation.VisibleForTesting;
import android.support.v4.app.FragmentActivity;

import com.facebook.login.LoginManager;
Expand Down Expand Up @@ -439,20 +439,17 @@ private abstract class AuthIntentBuilder<T extends AuthIntentBuilder> {
String mTosUrl;
boolean mIsSmartLockEnabled = true;

private AuthIntentBuilder() {
mProviders.add(new IdpConfig.Builder(EMAIL_PROVIDER).build());
}

private AuthIntentBuilder() {}

/**
* Specifies the theme to use for the application flow. If no theme is specified,
* a default theme will be used.
*/
public T setTheme(@StyleRes int theme) {
Preconditions.checkValidStyle(
mApp.getApplicationContext(),
theme,
"theme identifier is unknown or not a style definition");
mApp.getApplicationContext(),
theme,
"theme identifier is unknown or not a style definition");
mTheme = theme;
return (T) this;
}
Expand Down Expand Up @@ -542,12 +539,16 @@ public T setIsSmartLockEnabled(boolean enabled) {
return (T) this;
}

@CallSuper
public Intent build() {
if (mProviders.isEmpty()) {
mProviders.add(new IdpConfig.Builder(EMAIL_PROVIDER).build());
}

return KickoffActivity.createIntent(mApp.getApplicationContext(), getFlowParams());
}

@VisibleForTesting()
public abstract FlowParameters getFlowParams();
protected abstract FlowParameters getFlowParams();
}

/**
Expand All @@ -574,18 +575,17 @@ public ReauthIntentBuilder setReauthReason(String reauthReason) {
@Override
public Intent build() {
if (FirebaseAuth.getInstance(mApp).getCurrentUser() == null) {
throw new IllegalStateException(
"User must be currently logged in to reauthenticate");
throw new IllegalStateException("User must be currently logged in to reauthenticate");
}

return super.build();
}

@Override
public FlowParameters getFlowParams() {
protected FlowParameters getFlowParams() {
return new FlowParameters(
mApp.getName(),
new ArrayList<>(mProviders),
mProviders,
mTheme,
mLogo,
mTosUrl,
Expand Down Expand Up @@ -617,15 +617,10 @@ public SignInIntentBuilder setAllowNewEmailAccounts(boolean enabled) {
}

@Override
@VisibleForTesting()
public FlowParameters getFlowParams() {
if (mProviders.isEmpty()) {
mProviders.add(new IdpConfig.Builder(EMAIL_PROVIDER).build());
}

protected FlowParameters getFlowParams() {
return new FlowParameters(
mApp.getName(),
new ArrayList<>(mProviders),
mProviders,
mTheme,
mLogo,
mTosUrl,
Expand Down
10 changes: 7 additions & 3 deletions auth/src/test/java/com/firebase/ui/auth/AuthUITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.firebase.ui.auth.testhelpers.CustomRobolectricGradleTestRunner;
import com.firebase.ui.auth.testhelpers.TestConstants;
import com.firebase.ui.auth.testhelpers.TestHelper;
import com.firebase.ui.auth.ui.ExtraConstants;
import com.firebase.ui.auth.ui.FlowParameters;
import com.google.firebase.FirebaseApp;

Expand Down Expand Up @@ -48,7 +49,8 @@ public void testCreateStartIntent_deprecatedSetProvidersShouldStillWork() {
.getInstance(mFirebaseApp)
.createSignInIntentBuilder()
.setProviders(new String[]{AuthUI.EMAIL_PROVIDER, AuthUI.TWITTER_PROVIDER})
.getFlowParams();
.build()
.getParcelableExtra(ExtraConstants.EXTRA_FLOW_PARAMS);
assertEquals(2, flowParameters.providerInfo.size());
assertEquals(AuthUI.EMAIL_PROVIDER, flowParameters.providerInfo.get(0).getProviderId());
}
Expand All @@ -58,7 +60,8 @@ public void testCreateStartIntent_shouldHaveEmailAsDefaultProvider() {
FlowParameters flowParameters = AuthUI
.getInstance(mFirebaseApp)
.createSignInIntentBuilder()
.getFlowParams();
.build()
.getParcelableExtra(ExtraConstants.EXTRA_FLOW_PARAMS);
assertEquals(1, flowParameters.providerInfo.size());
assertEquals(AuthUI.EMAIL_PROVIDER, flowParameters.providerInfo.get(0).getProviderId());
}
Expand All @@ -79,7 +82,8 @@ public void testCreatingStartIntent() {
new IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
new IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build()))
.setTosUrl(TestConstants.TOS_URL)
.getFlowParams();
.build()
.getParcelableExtra(ExtraConstants.EXTRA_FLOW_PARAMS);

assertEquals(3, flowParameters.providerInfo.size());
assertEquals(mFirebaseApp.getName(), flowParameters.appName);
Expand Down