1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00
appwrite/public/scripts/init.js

32 lines
866 B
JavaScript
Raw Normal View History

2019-05-09 18:54:39 +12:00
// Init
window.ls.error = function() {
return function(error) {
2020-06-04 23:20:30 +12:00
window.console.error(error);
window.location = '/console';
};
2019-05-09 18:54:39 +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() {
window.location = "/auth/signin";
});
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
promise.then(function () {
window.location = '/console';
}, function (error) {
window.location = '/auth/signup?failure=1';
});
2020-02-04 08:20:10 +13:00
});