mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 16:06:21 +00:00
32dd070e49
* Self-host all libs (including but not limited to Font Awesome icons). LICENSE files were properly included as well. * Temporarily disabling error pages. * Added "start" and "pm2" scripts. To be used with "yarn SCRIPT_NAME" or "npm run SCRIPT_NAME". * Added container for the tables in dashboard. On narrow screens, such as phones, users will then have the ability to use horizontal scroll on the tables. * Fixed various resource paths. This should now work properly when not being hosted in root domain (e.i. https://fiery.me/lolisafe/). * Before checking API, the "Running in ..." button will now say "Loading..." instead.
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
/* global swal, axios */
|
|
|
|
var page = {}
|
|
|
|
page.do = function (dest) {
|
|
var user = document.getElementById('user').value
|
|
var pass = document.getElementById('pass').value
|
|
|
|
if (user === undefined || user === null || user === '') {
|
|
return swal('Error', 'You need to specify a username', 'error')
|
|
}
|
|
if (pass === undefined || pass === null || pass === '') {
|
|
return swal('Error', 'You need to specify a username', 'error')
|
|
}
|
|
|
|
axios.post('api/' + dest, {
|
|
username: user,
|
|
password: pass
|
|
})
|
|
.then(function (response) {
|
|
if (response.data.success === false) {
|
|
return swal('Error', response.data.description, 'error')
|
|
}
|
|
|
|
localStorage.token = response.data.token
|
|
window.location = 'dashboard'
|
|
})
|
|
.catch(function (error) {
|
|
console.log(error)
|
|
return swal('An error ocurred', 'There was an error with the request, please check the console for more information.', 'error')
|
|
})
|
|
}
|
|
|
|
page.verify = function () {
|
|
page.token = localStorage.token
|
|
if (page.token === undefined) return
|
|
|
|
axios.post('api/tokens/verify', {
|
|
token: page.token
|
|
})
|
|
.then(function (response) {
|
|
if (response.data.success === false) {
|
|
return swal('Error', response.data.description, 'error')
|
|
}
|
|
|
|
window.location = 'dashboard'
|
|
})
|
|
.catch(function (error) {
|
|
console.log(error)
|
|
return swal('An error ocurred', 'There was an error with the request, please check the console for more information.', 'error')
|
|
})
|
|
}
|
|
|
|
window.onload = function () {
|
|
page.verify()
|
|
}
|