mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-24 17:14:04 +02:00
fix confusing behaviour after logging out in the standalone build of iD (#10683)
when user logs out of osm.org via the logout button: the popup continues to the login screen, which if completed now logs the user back into iD with the new credentials
This commit is contained in:
@@ -1417,7 +1417,8 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
authenticate: function(callback) {
|
||||
/** @param {import('osm-auth').LoginOptions} options */
|
||||
authenticate: function(callback, options) {
|
||||
var that = this;
|
||||
var cid = _connectionID;
|
||||
_userChangesets = undefined;
|
||||
@@ -1444,7 +1445,7 @@ export default {
|
||||
locale: localizer.localeCode(),
|
||||
});
|
||||
|
||||
oauth.authenticate(done);
|
||||
oauth.authenticate(done, options);
|
||||
},
|
||||
|
||||
|
||||
|
||||
+6
-24
@@ -54,7 +54,12 @@ export function uiAccount(context) {
|
||||
.on('click', e => {
|
||||
e.preventDefault();
|
||||
osm.logout();
|
||||
tryLogout();
|
||||
// OAuth2's idea of "logout" is just to get rid of the bearer token.
|
||||
// If we try to "login" again, it will just grab the token again.
|
||||
// What a user probably _really_ expects is to logout of OSM so that they can switch users.
|
||||
// So, we open a popup with a "Logout" button. After logging out, they can login again using
|
||||
// the same popup window.
|
||||
osm.authenticate(undefined, { switchUser: true });
|
||||
});
|
||||
|
||||
} else { // no user
|
||||
@@ -75,29 +80,6 @@ export function uiAccount(context) {
|
||||
}
|
||||
|
||||
|
||||
// OAuth2's idea of "logout" is just to get rid of the bearer token.
|
||||
// If we try to "login" again, it will just grab the token again.
|
||||
// What a user probably _really_ expects is to logout of OSM so that they can switch users.
|
||||
function tryLogout() {
|
||||
if (!osm) return;
|
||||
|
||||
const url = osm.getUrlRoot() + '/logout?referer=%2Flogin';
|
||||
// Create a 600x550 popup window in the center of the screen
|
||||
const w = 600;
|
||||
const h = 550;
|
||||
const settings = [
|
||||
['width', w],
|
||||
['height', h],
|
||||
['left', window.screen.width / 2 - w / 2],
|
||||
['top', window.screen.height / 2 - h / 2],
|
||||
]
|
||||
.map(x => x.join('='))
|
||||
.join(',');
|
||||
|
||||
window.open(url, '_blank', settings);
|
||||
}
|
||||
|
||||
|
||||
return function(selection) {
|
||||
if (!osm) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user