mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 16:36:21 +00:00
47f2f30682
* Added Editor Config file. * Added ".vscode/" to .gitignore. * Added final newline to some files. * Added KDE Breeze Dark colors. * Applied various ESLint autofixes. There were still plenty of non-auto-fixable issues though. I'm not sure why this project had ESLint dev dependency but still ended up with countless issues. * ... and maybe some others.
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
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(response => {
|
|
if (response.data.success === false) { return swal('Error', response.data.description, 'error'); }
|
|
|
|
localStorage.token = response.data.token;
|
|
window.location = '/dashboard';
|
|
})
|
|
.catch(error => {
|
|
return swal('An error ocurred', 'There was an error with the request, please check the console for more information.', 'error');
|
|
console.log(error);
|
|
});
|
|
};
|
|
|
|
page.verify = function() {
|
|
page.token = localStorage.token;
|
|
if (page.token === undefined) return;
|
|
|
|
axios.post('/api/tokens/verify', { token: page.token })
|
|
.then(response => {
|
|
if (response.data.success === false) { return swal('Error', response.data.description, 'error'); }
|
|
|
|
window.location = '/dashboard';
|
|
})
|
|
.catch(error => {
|
|
return swal('An error ocurred', 'There was an error with the request, please check the console for more information.', 'error');
|
|
console.log(error);
|
|
});
|
|
};
|
|
|
|
window.onload = function() {
|
|
page.verify();
|
|
};
|