diff --git a/index.js b/index.js index 10a3804f..fea81439 100644 --- a/index.js +++ b/index.js @@ -218,10 +218,27 @@ module.exports = { token: res.token } - return; + return res; } - return await response.text(); + return response; + }, + + async signup(email, fullName, password) { + let response = await fetch(this.getServerURL() + '/api/signup', { + method: 'POST', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ email, fullName, password }) + }); + + if (response.status === 200) { + return await response.json(); + } + + return response; }, getServerURL() { diff --git a/model/document.js b/model/document.js index b00c4ac5..03798860 100644 --- a/model/document.js +++ b/model/document.js @@ -111,9 +111,15 @@ module.exports = class BaseDocument extends Observable { // set standard values on server-side only if (frappe.isServer) { let now = (new Date()).toISOString(); - if (!this.submitted) this.submitted = 0; + if (!this.submitted) { + this.submitted = 0; + } + if (!this.owner) { this.owner = frappe.session.user; + } + + if (!this.creation) { this.creation = now; }