mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
fix: home uploader standardized headers set
it'd previously set the string-representation for non-string values e.g. "null" for null, etc. auth token is now also set on as axios' default common headers, just like in dashboard.js, etc., to avoid re-setting it everytime
This commit is contained in:
parent
6c929efa7b
commit
29c05a9046
@ -218,6 +218,7 @@ page.preparePage = () => {
|
|||||||
|
|
||||||
page.verifyToken = token => {
|
page.verifyToken = token => {
|
||||||
return axios.post('api/tokens/verify', { token }).then(response => {
|
return axios.post('api/tokens/verify', { token }).then(response => {
|
||||||
|
axios.defaults.headers.common.token = token
|
||||||
localStorage[lsKeys.token] = token
|
localStorage[lsKeys.token] = token
|
||||||
page.token = token
|
page.token = token
|
||||||
|
|
||||||
@ -326,12 +327,7 @@ page.setActiveTab = index => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
page.fetchAlbums = () => {
|
page.fetchAlbums = () => {
|
||||||
return axios.get('api/albums', {
|
return axios.get('api/albums', { headers: { simple: '1' } }).then(response => {
|
||||||
headers: {
|
|
||||||
simple: '1',
|
|
||||||
token: page.token
|
|
||||||
}
|
|
||||||
}).then(response => {
|
|
||||||
if (response.data.success === false) {
|
if (response.data.success === false) {
|
||||||
return swal('An error occurred!', response.data.description, 'error')
|
return swal('An error occurred!', response.data.description, 'error')
|
||||||
}
|
}
|
||||||
@ -570,10 +566,9 @@ page.prepareDropzone = () => {
|
|||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
headers: {
|
headers: {
|
||||||
token: page.token,
|
|
||||||
// Unlike the options above (e.g. albumid, filelength, etc.),
|
// Unlike the options above (e.g. albumid, filelength, etc.),
|
||||||
// strip tags cannot yet be configured per file with this API
|
// strip tags cannot yet be configured per file with this API
|
||||||
striptags: page.stripTags
|
striptags: page.stripTags || ''
|
||||||
}
|
}
|
||||||
}).catch(error => page.formatAxiosError(error)).then(response => {
|
}).catch(error => page.formatAxiosError(error)).then(response => {
|
||||||
file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')
|
file.previewElement.querySelector('.descriptive-progress').classList.add('is-hidden')
|
||||||
@ -664,10 +659,9 @@ page.processUrlsQueue = () => {
|
|||||||
urls: [file.url]
|
urls: [file.url]
|
||||||
}, {
|
}, {
|
||||||
headers: {
|
headers: {
|
||||||
token: page.token,
|
albumid: page.album || '',
|
||||||
albumid: page.album,
|
age: page.uploadAge || '',
|
||||||
age: page.uploadAge,
|
filelength: page.fileLength || ''
|
||||||
filelength: page.fileLength
|
|
||||||
}
|
}
|
||||||
}).catch(error => page.formatAxiosError(error)).then(response => {
|
}).catch(error => page.formatAxiosError(error)).then(response => {
|
||||||
return finishedUrlUpload(file, response.data)
|
return finishedUrlUpload(file, response.data)
|
||||||
@ -794,10 +788,6 @@ page.createAlbum = () => {
|
|||||||
description: document.querySelector('#swalDescription').value.trim(),
|
description: document.querySelector('#swalDescription').value.trim(),
|
||||||
download: document.querySelector('#swalDownload').checked,
|
download: document.querySelector('#swalDownload').checked,
|
||||||
public: document.querySelector('#swalPublic').checked
|
public: document.querySelector('#swalPublic').checked
|
||||||
}, {
|
|
||||||
headers: {
|
|
||||||
token: page.token
|
|
||||||
}
|
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.data.success === false) {
|
if (response.data.success === false) {
|
||||||
return swal('An error occurred!', response.data.description, 'error')
|
return swal('An error occurred!', response.data.description, 'error')
|
||||||
|
Loading…
Reference in New Issue
Block a user