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
1 changed files with 15 additions and 8 deletions

View File

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