mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 13:18:15 +02:00
Give user the opportunity to switch users when logging out
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.
This commit is contained in:
committed by
Martin Raifer
parent
43fe6e9579
commit
34a2af0330
@@ -568,6 +568,11 @@ export default {
|
||||
},
|
||||
|
||||
|
||||
getUrlRoot: function() {
|
||||
return urlroot;
|
||||
},
|
||||
|
||||
|
||||
changesetURL: function(changesetID) {
|
||||
return urlroot + '/changeset/' + changesetID;
|
||||
},
|
||||
|
||||
@@ -54,6 +54,7 @@ export function uiAccount(context) {
|
||||
.on('click', e => {
|
||||
e.preventDefault();
|
||||
osm.logout();
|
||||
tryLogout();
|
||||
});
|
||||
|
||||
} else { // no user
|
||||
@@ -74,6 +75,29 @@ 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