1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Handle logging out and already logged-out editor

Fixes #1288
This commit is contained in:
Nick O'Leary 2017-06-26 10:49:06 +01:00
parent df9e50445e
commit e9c1216d5c
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -155,17 +155,24 @@ RED.user = (function() {
} }
function logout() { function logout() {
var tokens = RED.settings.get("auth-tokens");
var token = tokens?tokens.access_token:"";
$.ajax({ $.ajax({
url: "auth/revoke", url: "auth/revoke",
type: "POST", type: "POST",
data: {token:RED.settings.get("auth-tokens").access_token}, data: {token:token}
success: function(data) { }).done(function(data,textStatus,xhr) {
RED.settings.remove("auth-tokens"); RED.settings.remove("auth-tokens");
if (data && data.redirect) { if (data && data.redirect) {
document.location.href = data.redirect; document.location.href = data.redirect;
} else { } else {
document.location.reload(true); document.location.reload(true);
} }
}).fail(function(jqXHR,textStatus,errorThrown) {
if (jqXHR.status === 401) {
document.location.reload(true);
} else {
console.log(textStatus);
} }
}) })
} }