Skip to content

Commit

Permalink
Merge pull request #19244 from osmandapp/reset_oauth_token
Browse files Browse the repository at this point in the history
Reset oauth token on move to 2.0 version
  • Loading branch information
Chumva committed Mar 5, 2024
2 parents eef33b2 + 11d81a3 commit 2ae0fae
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.osmand.plus.plugins.osmedit.OsmEditingPlugin;
import net.osmand.plus.plugins.osmedit.helpers.OsmBugsRemoteUtil;
import net.osmand.plus.utils.AndroidUtils;
import net.osmand.util.Algorithms;

import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParserException;
Expand Down Expand Up @@ -78,8 +79,9 @@ public void resetToken() {

public void restoreToken() {
String token = plugin.OSM_USER_ACCESS_TOKEN.get();
String savedSecret = plugin.OSM_USER_ACCESS_TOKEN_SECRET.get();
String tokenSecret = client.getApiSecret();
if (!(token.isEmpty() || tokenSecret.isEmpty())) {
if (!(token.isEmpty() || tokenSecret.isEmpty()) && Algorithms.stringsEqual(savedSecret, tokenSecret)) {
client.setAccessToken(new OAuth2AccessToken(token, tokenSecret));
} else {
client.setAccessToken(null);
Expand All @@ -93,6 +95,7 @@ public void startOAuth(ViewGroup rootLayout, boolean nightMode) {
private void saveToken() {
OAuth2AccessToken accessToken = client.getAccessToken();
plugin.OSM_USER_ACCESS_TOKEN.set(accessToken.getAccessToken());
plugin.OSM_USER_ACCESS_TOKEN_SECRET.set(client.getApiSecret());
}

private void loadWebView(ViewGroup root, boolean nightMode, String url) {
Expand Down

0 comments on commit 2ae0fae

Please sign in to comment.