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:
Bryan Housel
2022-04-28 13:13:07 -04:00
committed by Martin Raifer
parent 43fe6e9579
commit 34a2af0330
2 changed files with 29 additions and 0 deletions
+5
View File
@@ -568,6 +568,11 @@ export default {
},
getUrlRoot: function() {
return urlroot;
},
changesetURL: function(changesetID) {
return urlroot + '/changeset/' + changesetID;
},
+24
View File
@@ -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;