From 23c02002b412609895676ff1a8d74b8117791dc2 Mon Sep 17 00:00:00 2001 From: jorgemucientesfayos Date: Mon, 18 Nov 2024 15:28:27 +0100 Subject: [PATCH] Updates Authenticator file to use API 1.3 for sign up links --- .../rest/wpcom/auth/Authenticator.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/auth/Authenticator.java b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/auth/Authenticator.java index ac0b045df9..2c7df83bc5 100644 --- a/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/auth/Authenticator.java +++ b/fluxc/src/main/java/org/wordpress/android/fluxc/network/rest/wpcom/auth/Authenticator.java @@ -5,15 +5,6 @@ import androidx.annotation.NonNull; -import com.android.volley.Cache; -import com.android.volley.NetworkResponse; -import com.android.volley.ParseError; -import com.android.volley.Request; -import com.android.volley.RequestQueue; -import com.android.volley.Response; -import com.android.volley.VolleyError; -import com.android.volley.toolbox.HttpHeaderParser; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -45,6 +36,15 @@ import javax.inject.Inject; import javax.inject.Named; +import com.android.volley.Cache; +import com.android.volley.NetworkResponse; +import com.android.volley.ParseError; +import com.android.volley.Request; +import com.android.volley.RequestQueue; +import com.android.volley.Response; +import com.android.volley.VolleyError; +import com.android.volley.toolbox.HttpHeaderParser; + public class Authenticator { private static final String WPCOM_OAUTH_PREFIX = "https://public-api.wordpress.com/oauth2"; private static final String WPCOM_PREFIX = "https://wordpress.com"; @@ -90,7 +90,8 @@ public AuthEmailResponsePayload(boolean isSignup) { } } - @Inject public Authenticator(Context appContext, + @Inject + public Authenticator(Context appContext, Dispatcher dispatcher, @Named("regular") RequestQueue requestQueue, AppSecrets secrets) { @@ -248,7 +249,8 @@ public BearerRequest(String appId, String appSecret, String code, Listener liste } } - public interface OauthResponse {} + public interface OauthResponse { + } public static class Token implements OauthResponse { private String mAccessToken; @@ -300,8 +302,7 @@ public TwoFactorResponse(JSONObject data) throws JSONException { } public void sendAuthEmail(final AuthEmailPayload payload) { - String url = payload.isSignup ? WPCOMREST.auth.send_signup_email.getUrlV1_1() - : WPCOMREST.auth.send_login_email.getUrlV1_3(); + String url = WPCOMREST.auth.send_login_email.getUrlV1_3(); Map params = new HashMap<>(); params.put("email", payload.emailOrUsername); @@ -326,6 +327,10 @@ public void sendAuthEmail(final AuthEmailPayload payload) { params.put("signup_flow_name", payload.signupFlowName); } + if(payload.isSignup) { + params.put("create_account", true); + } + WPComGsonRequest request = WPComGsonRequest.buildPostRequest(url, params, AuthEmailWPComRestResponse.class, new Response.Listener() { @Override