Skip to content

Commit

Permalink
Update Login2FaFragment callback interface and payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomazFB committed Oct 23, 2023
1 parent a25c4fc commit 5a430a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.wordpress.android.fluxc.store.AccountStore.AuthenticationErrorType;
import org.wordpress.android.fluxc.store.AccountStore.OnAuthenticationChanged;
import org.wordpress.android.fluxc.store.AccountStore.OnSocialChanged;
import org.wordpress.android.fluxc.store.AccountStore.OnWebauthnChallengeReceived;
import org.wordpress.android.fluxc.store.AccountStore.PushSecurityKeyPayload;
import org.wordpress.android.fluxc.store.AccountStore.PushSocialAuthPayload;
import org.wordpress.android.fluxc.store.AccountStore.PushSocialPayload;
Expand Down Expand Up @@ -336,8 +337,8 @@ private void doAuthWithSecurityKeyAction() {
if (!NetworkUtils.checkConnection(getActivity())) {
return;
}

PushSecurityKeyPayload payload = new PushSecurityKeyPayload(mUserId, mNonce);
//TODO: Check if security key is available, if not, trigger PushSecurityKeyPayload
PushSecurityKeyPayload payload = new PushSecurityKeyPayload(mEmailAddress, mPassword);
mDispatcher.dispatch(AuthenticationActionBuilder.newAuthenticateSecurityKeyAction(payload));
}

Expand Down Expand Up @@ -554,4 +555,14 @@ private void setTextForSms() {
mOtpButton.setText(getString(R.string.login_text_otp_another));
mSentSmsCode = true;
}

@SuppressWarnings("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
public void onWebauthnChallengeReceived(OnWebauthnChallengeReceived event) {
if (event.isError()) {
//TODO: Handle error
return;
}
mLoginListener.signSecurityKey(event.challengeInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import androidx.annotation.Nullable;

import org.wordpress.android.fluxc.network.MemorizingTrustManager;
import org.wordpress.android.fluxc.network.rest.wpcom.auth.passkey.WebauthnChallengeInfo;
import org.wordpress.android.fluxc.store.SiteStore;
import org.wordpress.android.fluxc.store.SiteStore.ConnectSiteInfoPayload;

Expand Down Expand Up @@ -50,8 +51,7 @@ void gotUnregisteredSocialAccount(String email, String displayName, String idTok
void needs2fa(String email, String password);
void needs2faSocial(String email, String userId, String nonceAuthenticator, String nonceBackup, String nonceSms);
void needs2faSocialConnect(String email, String password, String idToken, String service);
void needsSecurityKey(String userId, String nonceInfo);
void needsSocialSecurityKey(String userId, String nonceInfo);
void signSecurityKey(WebauthnChallengeInfo challengeInfo);
void loggedInViaPassword(ArrayList<Integer> oldSitesIds);
void helpEmailPasswordScreen(String email);

Expand Down

0 comments on commit 5a430a7

Please sign in to comment.