Better handling of permissions in frontend

This commit is contained in:
gmemstr 2017-11-29 13:23:54 -08:00
parent f3c011510d
commit 4351bb7e4e

View file

@ -205,6 +205,7 @@ const episodemanagement = {
} else {
var t = JSON.parse(items).items
for (var i = t.length - 1; i >= 0; i--) {
console.log(i)
this.items.push({
title: t[i].title,
url: t[i].url,
@ -312,11 +313,15 @@ const customcss = {
get("/admin/css", (err, css) => {
this.loading = false
if (css == "{}") {
this.css = "You aren't allowed to edit this CSS!"
} else {
if (err) {
this.error = err.toString()
} else {
this.css = css
}
}
})
}
}
@ -348,9 +353,14 @@ const app = new Vue({
function get(url,callback) {
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
if (xmlHttp.responseText == "Unauthorized") {
callback(null, "{}")
} else {
callback(null, xmlHttp.responseText)
}
}
}
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}