use of org.wikipedia.csrf.CsrfTokenClient in project apps-android-wikipedia by wikimedia.
the class EditSectionActivity method getEditTokenThenSave.
private void getEditTokenThenSave(boolean forceLogin) {
cancelCalls();
captchaHandler.hideCaptcha();
editSummaryFragment.saveSummary();
csrfClient = new CsrfTokenClient(title.getWikiSite(), title.getWikiSite());
csrfClient.request(forceLogin, new CsrfTokenClient.Callback() {
@Override
public void success(@NonNull String token) {
doSave(token);
}
@Override
public void failure(@NonNull Throwable caught) {
showError(caught);
}
@Override
public void twoFactorPrompt() {
showError(new LoginClient.LoginFailedException(getResources().getString(R.string.login_2fa_other_workflow_error_msg)));
}
});
}
use of org.wikipedia.csrf.CsrfTokenClient in project apps-android-wikipedia by wikimedia.
the class NotificationPollBroadcastReceiver method markRead.
public static void markRead(@NonNull WikiSite wiki, @NonNull List<Notification> notifications, boolean unread) {
final String idListStr = TextUtils.join("|", notifications);
CsrfTokenClient editTokenClient = new CsrfTokenClient(wiki, WikipediaApp.getInstance().getWikiSite());
editTokenClient.request(new CsrfTokenClient.DefaultCallback() {
@SuppressLint("CheckResult")
@Override
public void success(@NonNull String token) {
ServiceFactory.get(wiki).markRead(token, unread ? null : idListStr, unread ? idListStr : null).subscribeOn(Schedulers.io()).subscribe(response -> {
}, L::e);
}
});
}
Aggregations