Skip to content

Commit

Permalink
fix confusing behaviour after logging out in the standalone build of …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
k-yle authored Jan 22, 2025
1 parent edf41a9 commit add513f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
* Fix grid lines from showing up on background map tiles in certain situations (semi-transparent tiles or fractional browser zoom level) ([#10594], thanks [@Nekzuris])
* Prevent search results from sometimes getting stuck in the highlighted state when mouse-hovering the list of search results while typing ([#10661])
* Allow tiles in minimap to be slightly underzoomed, preventing them from blacking out on low map zoom levels ([#10653])
* Fix confusing behaviour after logging out in the standalone build of iD ([#10683], thanks [@k-yle])
#### :earth_asia: Localization
* Update Sinitic languages in the Multilingual Names field ([#10488], thanks [@winstonsung])
* Update the list of languages in the Wikipedia field ([#10489])
Expand All @@ -74,6 +75,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
[#10634]: https://github.com/openstreetmap/iD/issues/10634
[#10650]: https://github.com/openstreetmap/iD/issues/10650
[#10653]: https://github.com/openstreetmap/iD/issues/10653
[#10683]: https://github.com/openstreetmap/iD/issues/10683
[#10684]: https://github.com/openstreetmap/iD/pull/10684
[@winstonsung]: https://github.com/winstonsung/
[@Nekzuris]: https://github.com/Nekzuris
Expand Down
5 changes: 3 additions & 2 deletions modules/services/osm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -1444,7 +1445,7 @@ export default {
locale: localizer.localeCode(),
});

oauth.authenticate(done);
oauth.authenticate(done, options);
},


Expand Down
30 changes: 6 additions & 24 deletions modules/ui/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down

0 comments on commit add513f

Please sign in to comment.