Skip to content

Commit

Permalink
Merge pull request #152 from wordpress-mobile/fix-sms-2fa
Browse files Browse the repository at this point in the history
Fixes for the SMS 2FA
  • Loading branch information
hichamboushaba authored Aug 16, 2024
2 parents 6801864 + 194b875 commit 946482e
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.wordpress.android.login;

import static android.content.Context.CLIPBOARD_SERVICE;

import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;
Expand Down Expand Up @@ -53,8 +55,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static android.content.Context.CLIPBOARD_SERVICE;

import dagger.android.support.AndroidSupportInjection;

public class Login2FaFragment extends LoginBaseFormFragment<LoginListener> implements TextWatcher,
Expand Down Expand Up @@ -132,7 +132,6 @@ public static Login2FaFragment newInstance(String emailAddress, String password,
String userId, String webauthnNonce,
String authenticatorNonce, String backupNonce,
String smsNonce, List<String> authTypes) {
boolean supportsWebauthn = webauthnNonce != null && !webauthnNonce.isEmpty();
Login2FaFragment fragment = new Login2FaFragment();
Bundle args = new Bundle();
args.putString(ARG_EMAIL_ADDRESS, emailAddress);
Expand Down Expand Up @@ -208,7 +207,9 @@ protected void setupContent(ViewGroup rootView) {
// restrict the allowed input chars to just numbers
m2FaInput.getEditText().setKeyListener(DigitsKeyListener.getInstance("0123456789"));

boolean isSmsEnabled = mSupportedAuthTypes.contains(SupportedAuthTypes.PUSH);
// If we didn't get a list of supported auth types, then the flow is not using webauthn,
// We should treat it as if SMS is enabled for the user
boolean isSmsEnabled = mSupportedAuthTypes.isEmpty() || mSupportedAuthTypes.contains(SupportedAuthTypes.PUSH);
mOtpButton = rootView.findViewById(R.id.login_otp_button);
mOtpButton.setVisibility(isSmsEnabled ? View.VISIBLE : View.GONE);
mOtpButton.setText(mSentSmsCode ? R.string.login_text_otp_another : R.string.login_text_otp);
Expand Down

0 comments on commit 946482e

Please sign in to comment.