2019-05-09 18:54:39 +12:00
|
|
|
// Init
|
|
|
|
|
2019-09-13 22:47:07 +12:00
|
|
|
window.ls.error = function() {
|
|
|
|
return function(error) {
|
2020-06-04 23:20:30 +12:00
|
|
|
window.console.error(error);
|
2020-06-07 02:04:18 +12:00
|
|
|
|
|
|
|
if(window.location.pathname !== '/console') {
|
|
|
|
window.location = '/console';
|
|
|
|
}
|
2019-09-13 22:47:07 +12:00
|
|
|
};
|
2019-05-09 18:54:39 +12:00
|
|
|
};
|
|
|
|
|
2019-09-13 22:47:07 +12:00
|
|
|
window.addEventListener("error", function(event) {
|
|
|
|
console.error("ERROR-EVENT:", event.error.message, event.error.stack);
|
2019-05-09 18:54:39 +12:00
|
|
|
});
|
|
|
|
|
2020-02-04 08:20:10 +13:00
|
|
|
document.addEventListener("account.deleteSession", function() {
|
2019-09-13 22:47:07 +12:00
|
|
|
window.location = "/auth/signin";
|
2020-02-13 21:04:52 +13:00
|
|
|
});
|
|
|
|
|
|
|
|
document.addEventListener("account.create", function() {
|
|
|
|
let container = window.ls.container;
|
|
|
|
let form = container.get('serviceForm');
|
|
|
|
let sdk = container.get('console');
|
|
|
|
|
|
|
|
let promise = sdk.account.createSession(form.email, form.password);
|
|
|
|
|
2020-02-18 18:25:28 +13:00
|
|
|
container.set("serviceForm", {}, true, true); // Remove sensetive data when not needed
|
2020-02-13 21:04:52 +13:00
|
|
|
|
|
|
|
promise.then(function () {
|
|
|
|
window.location = '/console';
|
|
|
|
}, function (error) {
|
|
|
|
window.location = '/auth/signup?failure=1';
|
|
|
|
});
|
2020-02-04 08:20:10 +13:00
|
|
|
});
|