[gnome-maps/wip/osm-edit: 9/11] osmEdit: Remove stop-gap solutions for password authentication
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/osm-edit: 9/11] osmEdit: Remove stop-gap solutions for password authentication
- Date: Sat, 5 Dec 2015 21:10:59 +0000 (UTC)
commit 0cb5de3f3982b19e318f1e867175dd15ead14c9f
Author: Marcus Lundblad <ml update uu se>
Date: Tue Dec 1 22:29:51 2015 +0100
osmEdit: Remove stop-gap solutions for password authentication
src/osmConnection.js | 85 +-------------------------------------------------
src/osmEdit.js | 4 --
src/placeBubble.js | 14 +++-----
3 files changed, 7 insertions(+), 96 deletions(-)
---
diff --git a/src/osmConnection.js b/src/osmConnection.js
index d547100..77955d0 100644
--- a/src/osmConnection.js
+++ b/src/osmConnection.js
@@ -32,7 +32,6 @@ const Secret = imports.gi.Secret;
const Soup = imports.gi.Soup;
const BASE_URL = 'https://api.openstreetmap.org/api';
-const TEST_BASE_URL = 'http://api06.dev.openstreetmap.org/api';
const API_VERSION = '0.6';
/* OAuth constants */
@@ -59,31 +58,9 @@ const OSMConnection = new Lang.Class({
this._callProxy = Rest.OAuthProxy.new(CONSUMER_KEY, CONSUMER_SECRET,
BASE_URL + '/' + API_VERSION,
false);
-
- /* TODO: stopgap to supply username/password
- to use with HTTP basic auth, should be
- replaced with OAUTH and real settings */
- this._username = GLib.getenv('OSM_USERNAME');
- this._password = GLib.getenv('OSM_PASSWORD');
-
- let useLiveApi = GLib.getenv('OSM_USE_LIVE_API');
-
- /* for now use the test API unless explicitly
- set to use the live one */
- if (useLiveApi == 'yes')
- this._useTestApi = false;
- else
- this._useTestApi = true;
-
- this._session.connect('authenticate', this._authenticate.bind(this));
-
Maps.osm_init();
},
- get useTestAPI() {
- return this._useTestApi;
- },
-
getOSMObject: function(type, id, callback, cancellable) {
let url = this._getQueryUrl(type, id);
let uri = new Soup.URI(url);
@@ -112,19 +89,7 @@ const OSMConnection = new Lang.Class({
},
_getQueryUrl: function(type, id) {
- if (this._useTestApi) {
- /* override object type and ID from a mock object
- since the object we get from Nominatim and Overpass
- doesn't exist in the test OSM environment */
- type = GLib.getenv('OSM_MOCK_TYPE');
- id = GLib.getenv('OSM_MOCK_ID');
- }
-
- return this._getBaseUrl() + '/' + API_VERSION + '/' + type + '/' + id;
- },
-
- _getBaseUrl: function() {
- return this._useTestApi ? TEST_BASE_URL : BASE_URL;
+ return BASE_URL + '/' + API_VERSION + '/' + type + '/' + id;
},
openChangeset: function(comment, callback) {
@@ -258,36 +223,10 @@ const OSMConnection = new Lang.Class({
callback(true, call.get_status_code(), call.get_payload());
},
- _getOpenChangesetUrl: function() {
- return this._getBaseUrl() + '/' + API_VERSION + '/changeset/create';
- },
-
- _getCloseChangesetUrl: function(changesetId) {
- return this._getBaseUrl() + '/' + API_VERSION + '/changeset/' +
- changesetId + '/close';
- },
-
_getCloseChangesetFunction: function(changesetId) {
return '/changeset/' + changesetId + '/close';
},
- _getCreateOrUpdateUrl: function(object, type) {
- if (object.id) {
- let id = object.id;
- if (this._useTestApi) {
- /* override object type and ID from a mock object
- since the object we get from Nominatim and Overpass
- doesn't exist in the test OSM environment */
- type = GLib.getenv('OSM_MOCK_TYPE');
- id = GLib.getenv('OSM_MOCK_ID');
- }
-
- return this._getBaseUrl() + '/' + API_VERSION + '/' + type + '/' + id;
- } else {
- return this._getBaseUrl() + '/' + API_VERSION + '/' + type + '/create';
- }
- },
-
_getCreateOrUpdateFunction: function(object, type) {
if (object.id)
return type + '/' + object.id;
@@ -295,32 +234,10 @@ const OSMConnection = new Lang.Class({
return type + '/create';
},
- _getDeleteUrl: function(object, type) {
- let id = object.id;
-
- if (this._useTestApi) {
- /* override object type and ID from a mock object
- since the object we get from Nominatim and Overpass
- doesn't exist in the test OSM environment */
- type = GLib.getenv('OSM_MOCK_TYPE');
- id = GLib.getenv('OSM_MOCK_ID');
- }
-
- return this._getBaseUrl() + '/' + API_VERSION + '/' + type + '/' + id;
- },
-
_getDeleteFunction: function(object, type) {
return type + '/' + id;
},
- _authenticate: function(session, msg, auth, retrying, user_data) {
- Utils.debug('authenticate triggered');
- if (retrying)
- session.cancel_message(msg, Soup.Status.UNAUTHORIZED);
-
- auth.authenticate(this._username, this._password);
- },
-
requestOAuthToken: function(callback) {
this._oauthProxy.request_token_async('request_token', 'oob',
function(proxy, error, weakObject,
diff --git a/src/osmEdit.js b/src/osmEdit.js
index 6c88cec..f4a9d60 100644
--- a/src/osmEdit.js
+++ b/src/osmEdit.js
@@ -40,10 +40,6 @@ const OSMEdit = new Lang.Class({
this._isSignedIn = this._username !== null && this._username.length > 0;
},
- get useTestApi() {
- return this._osmConnection.useTestApi;
- },
-
get object() {
return this._osmObject;
},
diff --git a/src/placeBubble.js b/src/placeBubble.js
index 8fd87de..ab4d4df 100644
--- a/src/placeBubble.js
+++ b/src/placeBubble.js
@@ -163,14 +163,12 @@ const PlaceBubble = new Lang.Class({
switch (response) {
case OSMEditDialog.Response.UPLOADED:
- if (!Application.osmEdit.useTestApi) {
- // update place
- let object = Application.osmEdit.object;
- OSMUtils.updatePlaceFromOSMObject(this._place, object);
- // refresh place view
- this._clearView();
- this._populate(this._place);
- }
+ // update place
+ let object = Application.osmEdit.object;
+ OSMUtils.updatePlaceFromOSMObject(this._place, object);
+ // refresh place view
+ this._clearView();
+ this._populate(this._place);
break;
default:
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]