settings.js: when logged out, redirect to index

This commit is contained in:
codl 2017-09-02 15:07:40 +02:00
parent 109cbf31d9
commit feef504fa0
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
1 changed files with 12 additions and 2 deletions

View File

@ -92,7 +92,9 @@ import Banner from '../components/Banner.html';
},
body: JSON.stringify(body)
})
.then(resp => { if(!resp.ok){ return Promise.reject(resp); } return resp; })
.then(resp => {
if(!resp.ok){ return Promise.reject(resp); }
return resp; })
.then(resp => resp.json())
.then(data => {
if(data.status == 'error'){ return Promise.reject(data); }
@ -123,7 +125,15 @@ import Banner from '../components/Banner.html';
return fetch('/api/viewer', {
credentials: 'same-origin',
})
.then(resp => { if(!resp.ok){ return Promise.reject(resp); } return resp; })
.then(resp => {
if(!resp.ok){
if(resp.status == 403){
// user was logged out in another client
window.location = '/';
}
return Promise.reject(resp);
}
return resp; })
.then(resp => resp.json());
}