Skip to content

Commit

Permalink
Updates Authenticator file to use API 1.3 for sign up links
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeMucientes committed Nov 18, 2024
1 parent cc17141 commit 23c0200
Showing 1 changed file with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> params = new HashMap<>();
params.put("email", payload.emailOrUsername);
Expand All @@ -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<AuthEmailWPComRestResponse>() {
@Override
Expand Down

0 comments on commit 23c0200

Please sign in to comment.