Skip to content

Commit b2912b8

Browse files
authored
Revert reauthentication (#734)
1 parent cea4ec1 commit b2912b8

File tree

11 files changed

+14
-205
lines changed

11 files changed

+14
-205
lines changed

app/src/main/java/com/firebase/uidemo/auth/SignedInActivity.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@
5353
import butterknife.OnClick;
5454

5555
public class SignedInActivity extends AppCompatActivity {
56-
private static final String EXTRA_SIGNED_IN_CONFIG = "extra_signed_in_config";
5756

58-
private static final int RC_REAUTH = 100;
57+
private static final String EXTRA_SIGNED_IN_CONFIG = "extra_signed_in_config";
5958

6059
@BindView(android.R.id.content)
6160
View mRootView;
@@ -113,21 +112,6 @@ public void onComplete(@NonNull Task<Void> task) {
113112
});
114113
}
115114

116-
@OnClick(R.id.reauthenticate)
117-
public void reauthenticate() {
118-
Intent reauthIntent = AuthUI.getInstance()
119-
.createReauthIntentBuilder()
120-
.setAvailableProviders(mSignedInConfig.providerInfo)
121-
.setIsSmartLockEnabled(mSignedInConfig.isSmartLockEnabled)
122-
.setLogo(mSignedInConfig.logo)
123-
.setTheme(mSignedInConfig.theme)
124-
.setTosUrl(mSignedInConfig.tosUrl)
125-
.setReauthReason(getString(R.string.reauthentication_reason))
126-
.build();
127-
128-
startActivityForResult(reauthIntent, RC_REAUTH);
129-
}
130-
131115
@OnClick(R.id.delete_account)
132116
public void deleteAccountClicked() {
133117

@@ -298,14 +282,4 @@ public static Intent createIntent(
298282
return startIntent.setClass(context, SignedInActivity.class)
299283
.putExtra(EXTRA_SIGNED_IN_CONFIG, signedInConfig);
300284
}
301-
302-
@Override
303-
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
304-
super.onActivityResult(requestCode, resultCode, data);
305-
if (requestCode == RC_REAUTH) {
306-
mIdpResponse = IdpResponse.fromResultIntent(data);
307-
populateIdpToken();
308-
populateProfile();
309-
}
310-
}
311285
}

app/src/main/res/layout/signed_in_layout.xml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@
4040
android:layout_margin="16dp"
4141
android:text="@string/sign_out"/>
4242

43-
<Button
44-
android:id="@+id/reauthenticate"
45-
style="@style/Widget.AppCompat.Button.Colored"
46-
android:layout_width="wrap_content"
47-
android:layout_height="wrap_content"
48-
android:layout_gravity="center"
49-
android:layout_margin="16dp"
50-
android:text="@string/reauthenticate"/>
51-
5243
<Button
5344
android:id="@+id/delete_account"
5445
android:layout_width="wrap_content"

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@
6767
<string name="choose_image">Choose Image</string>
6868
<string name="accessibility_downloaded_image">Downloaded image</string>
6969
<string name="allow_new_email_acccount">Allow account creation if email does not exist.</string>
70-
<string name="reauthenticate">Reauth</string>
71-
<string name="reauthentication_reason">Reauth was requested from the test app. Please login to continue.</string>
7270

7371
<!-- strings for database demo activities -->
7472
<string name="start_chatting">No messages. Start chatting at the bottom!</string>

auth/src/main/java/com/firebase/ui/auth/AuthUI.java

Lines changed: 2 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,6 @@ public SignInIntentBuilder createSignInIntentBuilder() {
316316
return new SignInIntentBuilder();
317317
}
318318

319-
/**
320-
* Starts the reauthentication flow.
321-
*/
322-
public ReauthIntentBuilder createReauthIntentBuilder() {
323-
return new ReauthIntentBuilder();
324-
}
325-
326319
/**
327320
* Configuration for an identity provider.
328321
* <p>
@@ -441,7 +434,7 @@ public IdpConfig build() {
441434
}
442435

443436
/**
444-
* Base builder for both {@link SignInIntentBuilder} and {@link ReauthIntentBuilder}
437+
* Base builder for both {@link SignInIntentBuilder}.
445438
*/
446439
@SuppressWarnings(value = "unchecked")
447440
private abstract class AuthIntentBuilder<T extends AuthIntentBuilder> {
@@ -602,52 +595,6 @@ public Intent build() {
602595
protected abstract FlowParameters getFlowParams();
603596
}
604597

605-
/**
606-
* Builder for the intent to start the reauthentication flow.
607-
*/
608-
public final class ReauthIntentBuilder extends AuthIntentBuilder<ReauthIntentBuilder> {
609-
private String mReauthReason;
610-
611-
private ReauthIntentBuilder() {
612-
super();
613-
}
614-
615-
/**
616-
* Set an explanation for why reauth was requested e.g. "To delete your account you must
617-
* reauthenticate."
618-
*
619-
* @param reauthReason A string explaining why reauthentication was requested.
620-
*/
621-
public ReauthIntentBuilder setReauthReason(String reauthReason) {
622-
mReauthReason = reauthReason;
623-
return this;
624-
}
625-
626-
@Override
627-
public Intent build() {
628-
if (FirebaseAuth.getInstance(mApp).getCurrentUser() == null) {
629-
throw new IllegalStateException("User must be currently logged in to reauthenticate");
630-
}
631-
632-
return super.build();
633-
}
634-
635-
@Override
636-
protected FlowParameters getFlowParams() {
637-
return new FlowParameters(
638-
mApp.getName(),
639-
mProviders,
640-
mTheme,
641-
mLogo,
642-
mTosUrl,
643-
mPrivacyPolicyUrl,
644-
mIsSmartLockEnabled,
645-
false,
646-
true,
647-
mReauthReason);
648-
}
649-
}
650-
651598
/**
652599
* Builder for the intent to start the user authentication flow.
653600
*/
@@ -678,9 +625,7 @@ protected FlowParameters getFlowParams() {
678625
mTosUrl,
679626
mPrivacyPolicyUrl,
680627
mIsSmartLockEnabled,
681-
mAllowNewEmailAccounts,
682-
false,
683-
null);
628+
mAllowNewEmailAccounts);
684629
}
685630
}
686631
}

auth/src/main/java/com/firebase/ui/auth/KickoffActivity.java

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
import android.content.Context;
44
import android.content.DialogInterface;
5-
import android.content.DialogInterface.OnClickListener;
65
import android.content.Intent;
76
import android.net.ConnectivityManager;
87
import android.os.Bundle;
98
import android.support.annotation.RestrictTo;
10-
import android.support.v7.app.AlertDialog;
11-
import android.text.TextUtils;
129
import android.util.Log;
10+
1311
import com.firebase.ui.auth.ui.ActivityHelper;
1412
import com.firebase.ui.auth.ui.ExtraConstants;
1513
import com.firebase.ui.auth.ui.FlowParameters;
@@ -87,41 +85,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
8785

8886
private void start() {
8987
FlowParameters flowParams = mActivityHelper.getFlowParams();
90-
if (flowParams.isReauth) {
91-
showReauthDialog();
92-
} else {
93-
SignInDelegate.delegate(this, flowParams);
94-
}
95-
}
96-
97-
private void showReauthDialog() {
98-
final FlowParameters flowParams = mActivityHelper.getFlowParams();
99-
AlertDialog.Builder builder = new AlertDialog.Builder(this)
100-
.setTitle(R.string.reauth_dialog_title)
101-
.setOnCancelListener(new DialogInterface.OnCancelListener() {
102-
@Override
103-
public void onCancel(DialogInterface dialog) {
104-
finish(ResultCodes.CANCELED, new Intent());
105-
}
106-
})
107-
.setPositiveButton(R.string.sign_in_default, new OnClickListener() {
108-
@Override
109-
public void onClick(DialogInterface dialog, int which) {
110-
SignInDelegate.delegate(KickoffActivity.this, flowParams);
111-
}
112-
})
113-
.setNegativeButton(android.R.string.cancel, new OnClickListener() {
114-
@Override
115-
public void onClick(DialogInterface dialog, int which) {
116-
finish(ResultCodes.CANCELED, new Intent());
117-
}
118-
});
119-
120-
if (!TextUtils.isEmpty(flowParams.reauthReason)) {
121-
builder.setMessage(flowParams.reauthReason);
122-
}
123-
124-
builder.create().show();
88+
SignInDelegate.delegate(this, flowParams);
12589
}
12690

12791
/**

auth/src/main/java/com/firebase/ui/auth/ui/FlowParameters.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ public class FlowParameters implements Parcelable {
5555

5656
public final boolean allowNewEmailAccounts;
5757

58-
@Nullable
59-
public final String reauthReason;
60-
public final boolean isReauth;
61-
6258
public FlowParameters(
6359
@NonNull String appName,
6460
@NonNull List<IdpConfig> providerInfo,
@@ -67,9 +63,7 @@ public FlowParameters(
6763
@Nullable String termsOfServiceUrl,
6864
@Nullable String privacyPolicyUrl,
6965
boolean smartLockEnabled,
70-
boolean allowNewEmailAccounts,
71-
boolean isReauth,
72-
String reauthReason) {
66+
boolean allowNewEmailAccounts) {
7367
this.appName = Preconditions.checkNotNull(appName, "appName cannot be null");
7468
this.providerInfo = Collections.unmodifiableList(
7569
Preconditions.checkNotNull(providerInfo, "providerInfo cannot be null"));
@@ -79,8 +73,6 @@ public FlowParameters(
7973
this.privacyPolicyUrl = privacyPolicyUrl;
8074
this.smartLockEnabled = smartLockEnabled;
8175
this.allowNewEmailAccounts = allowNewEmailAccounts;
82-
this.isReauth = isReauth;
83-
this.reauthReason = reauthReason;
8476
}
8577

8678
@Override
@@ -93,8 +85,6 @@ public void writeToParcel(Parcel dest, int flags) {
9385
dest.writeString(privacyPolicyUrl);
9486
dest.writeInt(smartLockEnabled ? 1 : 0);
9587
dest.writeInt(allowNewEmailAccounts ? 1 : 0);
96-
dest.writeInt(isReauth ? 1 : 0);
97-
dest.writeString(reauthReason);
9888
}
9989

10090
@Override
@@ -124,9 +114,7 @@ public FlowParameters createFromParcel(Parcel in) {
124114
termsOfServiceUrl,
125115
privacyPolicyUrl,
126116
smartLockEnabled,
127-
allowNewEmailAccounts,
128-
isReauth,
129-
reauthReason);
117+
allowNewEmailAccounts);
130118
}
131119

132120
@Override

auth/src/main/java/com/firebase/ui/auth/ui/accountlink/WelcomeBackPasswordPrompt.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,9 @@ protected void onCreate(Bundle savedInstanceState) {
9494
ImeHelper.setImeOnDoneListener(mPasswordField, this);
9595

9696
// Create welcome back text with email bolded.
97-
String bodyText;
97+
String bodyText = getString(R.string.welcome_back_password_prompt_body, mEmail);
9898
FlowParameters flowParameters = mActivityHelper.getFlowParams();
99-
if (flowParameters.isReauth) {
100-
welcomeBackHeader.setText(getString(R.string.welcome_back_email_header_reauth));
101-
bodyText = getString(R.string.reauth_welcome_back_password_prompt_body, mEmail);
102-
} else {
103-
bodyText = getString(R.string.welcome_back_password_prompt_body, mEmail);
104-
}
99+
105100
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(bodyText);
106101
int emailStart = bodyText.indexOf(mEmail);
107102
spannableStringBuilder.setSpan(new StyleSpan(Typeface.BOLD),

auth/src/main/java/com/firebase/ui/auth/ui/email/RegisterEmailActivity.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ protected void onCreate(Bundle savedInstanceState) {
6565
// Get email from intent (can be null)
6666
String email = getIntent().getExtras().getString(ExtraConstants.EXTRA_EMAIL);
6767

68-
if (mActivityHelper.getFlowParams().isReauth) {
69-
email = mActivityHelper.getCurrentUser().getEmail();
70-
}
71-
7268
// Start with check email
7369
CheckEmailFragment fragment = CheckEmailFragment.newInstance(
7470
mActivityHelper.getFlowParams(), email);

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

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,6 @@ public void onCreate(Bundle savedInstance) {
9494
}
9595

9696
FlowParameters flowParams = mHelper.getFlowParams();
97-
if (flowParams.isReauth) {
98-
// if it's a reauth and it's not an email account, skip Smart Lock.
99-
List<String> providers = mHelper.getCurrentUser().getProviders();
100-
if (providers == null || providers.size() > 0) {
101-
// this is a non-email user, skip Smart Lock
102-
startAuthMethodChoice();
103-
return;
104-
}
105-
}
10697
if (flowParams.smartLockEnabled) {
10798
mHelper.showLoadingDialog(R.string.progress_dialog_loading);
10899

@@ -248,29 +239,8 @@ private void startAuthMethodChoice() {
248239
providerIdToConfig.put(providerConfig.getProviderId(), providerConfig);
249240
}
250241

251-
List<IdpConfig> visibleProviders = new ArrayList<>();
252-
if (flowParams.isReauth) {
253-
// For reauth flow we only want to show the IDPs which the user has associated with
254-
// their account.
255-
List<String> providerIds = mHelper.getCurrentUser().getProviders();
256-
if (providerIds.size() == 0) {
257-
// zero providers indicates that it is an email account
258-
visibleProviders.add(new IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build());
259-
} else {
260-
for (String providerId : providerIds) {
261-
IdpConfig idpConfig = providerIdToConfig.get(providerId);
262-
if (idpConfig == null) {
263-
Log.e(TAG, "User has provider " + providerId + " associated with their "
264-
+ "account, but only the following IDPs have been configured: "
265-
+ TextUtils.join(", ", providerIdToConfig.keySet()));
266-
} else {
267-
visibleProviders.add(idpConfig);
268-
}
269-
}
270-
}
271-
} else {
272-
visibleProviders = idpConfigs;
273-
}
242+
List<IdpConfig> visibleProviders = idpConfigs;
243+
274244
// If the only provider is Email, immediately launch the email flow. Otherwise, launch
275245
// the auth method picker screen.
276246
if (visibleProviders.size() == 1) {
@@ -279,10 +249,8 @@ private void startAuthMethodChoice() {
279249
RegisterEmailActivity.createIntent(getContext(), flowParams),
280250
RC_EMAIL_FLOW);
281251
} else {
282-
String email = flowParams.isReauth ? mHelper.getCurrentUser().getEmail() : null;
283-
redirectToIdpSignIn(email,
284-
providerIdToAccountType(visibleProviders.get(0)
285-
.getProviderId()));
252+
redirectToIdpSignIn(null, providerIdToAccountType(
253+
visibleProviders.get(0).getProviderId()));
286254
}
287255
} else {
288256
startActivityForResult(

auth/src/main/res/values/strings.xml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
<string name="sign_in_default">Sign in</string>
88
<string name="general_error">An error has occurred.</string>
99

10-
<!-- Reauth Dialog -->
11-
<string name="reauth_dialog_title">This action requires you to sign in before continuing.</string>
12-
1310
<!-- Provider -->
1411
<string name="idp_name_google">Google</string>
1512
<string name="idp_name_facebook">Facebook</string>
@@ -55,7 +52,6 @@
5552
<string name="title_welcome_back_password_prompt">@string/sign_in_default</string>
5653
<string name="welcome_back_idp_header">You already have an account</string>
5754
<string name="welcome_back_email_header">Welcome back!</string>
58-
<string name="welcome_back_email_header_reauth">Reauthentication required</string>
5955
<string name="welcome_back_idp_prompt">
6056
You\'ve already used <xliff:g id="email_addr" example="[email protected]">%1$s</xliff:g>.
6157
Sign in with <xliff:g id="provider_name" example="Google">%2$s</xliff:g> to continue.
@@ -64,10 +60,6 @@
6460
You\'ve already used <xliff:g id="email_addr" example="[email protected]">%1$s</xliff:g>
6561
to sign in. Enter your password for that account.
6662
</string>
67-
<string name="reauth_welcome_back_password_prompt_body">
68-
You must reauthenticate to continue. Please enter the password for the account with email
69-
<xliff:g id="email_addr" example="[email protected]">%1$s</xliff:g>.
70-
</string>
7163
<string name="progress_dialog_signing_in">Signing in…</string>
7264
<string name="trouble_signing_in">Trouble signing in?</string>
7365

auth/src/test/java/com/firebase/ui/auth/testhelpers/TestHelper.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ public static FlowParameters getFlowParameters(List<String> providerIds) {
6464
null /* tosUrl */,
6565
null /* privacyPolicyUrl */,
6666
true /* smartLockEnabled */,
67-
true /* allowNewEmailAccounts */,
68-
false /* isReauth */,
69-
null /* reauthReason */);
67+
true /* allowNewEmailAccounts */);
7068
}
7169

7270
public static void verifySmartLockSave(String providerId, String email, String password) {

0 commit comments

Comments
 (0)