Clear cached userDetails when auth events occur (fixes #2588)

This commit is contained in:
Bryan Housel
2015-04-21 23:11:14 -04:00
parent 61bfc1d993
commit bfbd1f2d1d

View File

@@ -18,8 +18,10 @@ iD.Connection = function() {
nodeStr = 'node',
wayStr = 'way',
relationStr = 'relation',
userDetails,
off;
connection.changesetURL = function(changesetId) {
return url + '/changeset/' + changesetId;
};
@@ -283,8 +285,6 @@ iD.Connection = function() {
});
};
var userDetails;
connection.userDetails = function(callback) {
if (userDetails) {
callback(undefined, userDetails);
@@ -411,6 +411,7 @@ iD.Connection = function() {
};
connection.flush = function() {
userDetails = undefined;
_.forEach(inflight, abortRequest);
loadedTiles = {};
inflight = {};
@@ -424,12 +425,14 @@ iD.Connection = function() {
};
connection.logout = function() {
userDetails = undefined;
oauth.logout();
event.auth();
return connection;
};
connection.authenticate = function(callback) {
userDetails = undefined;
function done(err, res) {
event.auth();
if (callback) callback(err, res);