fix login redirect

This commit is contained in:
Tyler Murphy 2023-02-13 11:59:00 -05:00
parent 98f612774c
commit df95f2a01c
4 changed files with 18 additions and 2 deletions

View file

@ -8,7 +8,7 @@ const fileRequest = async (url, file, method) => {
headers: {}
});
if (response.status == 401) {
location.href = 'login'
location.href = '/login'
}
const contentType = response.headers.get("content-type");
if (contentType && contentType.indexOf("application/json") !== -1) {
@ -31,7 +31,7 @@ const request = async (url, body, method) => {
}
});
if (response.status == 401) {
location.href = 'login'
location.href = '/login'
}
const contentType = response.headers.get("content-type");
if (contentType && contentType.indexOf("application/json") !== -1) {

View file

@ -141,6 +141,12 @@ async function init() {
}
data.self = request.json
if (request.json == undefined) {
location.href = '/login'
return
}
data.users[data.self.user_id] = data.self
const posts = await load()

View file

@ -75,6 +75,11 @@ async function init() {
throw new Error("Rate limited");
}
if (request.json == undefined) {
location.href = '/login'
return
}
data.self = request.json
const users = await load()

View file

@ -245,6 +245,11 @@ async function init() {
throw new Error("Rate limited");
}
if (request.json == undefined) {
location.href = '/login'
return
}
data.self = request.json;
data.users[data.self.user_id] = data.self