Skip to content

Commit

Permalink
Merge pull request #3110 from wordpress-mobile/issue/12935-update-log…
Browse files Browse the repository at this point in the history
…in-email-endpoint

Updates Authenticator file to use API 1.3 for sign up links
  • Loading branch information
hichamboushaba authored Nov 19, 2024
2 parents 800a917 + 717e419 commit 3b731c3
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
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 All @@ -345,7 +350,7 @@ public void onErrorResponse(@NonNull WPComGsonNetworkError error) {
mDispatcher.dispatch(AuthenticationActionBuilder.newSentAuthEmailAction(responsePayload));
}
}
);
);
request.addQueryParameter("locale", LanguageUtils.getPatchedCurrentDeviceLanguage(mAppContext));

mRequestQueue.add(request);
Expand Down

0 comments on commit 3b731c3

Please sign in to comment.