diff --git a/auth/auth.js b/auth/auth.js index a9b55bf3..e65879c1 100644 --- a/auth/auth.js +++ b/auth/auth.js @@ -64,11 +64,12 @@ module.exports = () => { email: user.name, exp: timeInSecondsAfterHr(24) }; + const token = jwt.encode(payload, jwtSecret); res.json({ token: token }); - } catch(e) { + } catch (e) { console.error(e); res.sendStatus(401); } @@ -100,7 +101,7 @@ module.exports = () => { res.json({ user: user.email }); - } catch(e) { + } catch (e) { console.error(e); res.status(500).send('Something went wrong!'); } @@ -108,6 +109,6 @@ module.exports = () => { }; }; -function timeInSecondsAfterHr(hour=1) { +function timeInSecondsAfterHr(hour = 1) { return Math.floor(Date.now() / 1000) + (3600 * hour) } \ No newline at end of file diff --git a/docs/models/controllers.md b/docs/models/controllers.md index 7914bf9f..4898a092 100644 --- a/docs/models/controllers.md +++ b/docs/models/controllers.md @@ -50,14 +50,14 @@ class todo_meta extends frappe.meta.Meta { Standard events on which you can bind handlers are -- `before_insert` -- `before_update` +- `beforeInsert` +- `beforeUpdate` - `validate` (called before any write) -- `after_insert`, -- `after_update` (called after any write) -- `before_submit` -- `after_submit` -- `before_cancel` -- `after_cancel` -- `before_delete` -- `after_delete` +- `afterInsert`, +- `afterUpdate` (called after any write) +- `beforeSubmit` +- `afterSubmit` +- `beforeCancel` +- `afterCancel` +- `beforeDelete` +- `afterDelete` diff --git a/model/document.js b/model/document.js index 03798860..a5bf4f44 100644 --- a/model/document.js +++ b/model/document.js @@ -274,9 +274,9 @@ module.exports = class BaseDocument extends Observable { } async delete() { - await this.trigger('before_delete'); + await this.trigger('beforeDelete'); await frappe.db.delete(this.doctype, this.name); - await this.trigger('after_delete'); + await this.trigger('afterDelete'); } async submit() { diff --git a/utils/format.js b/utils/format.js index c863f849..2fb84c1f 100644 --- a/utils/format.js +++ b/utils/format.js @@ -6,10 +6,10 @@ const frappe = require('frappejs'); module.exports = { format(value, field) { if (typeof field === 'string') { - field = {fieldtype: field}; + field = { fieldtype: field }; } - if (field.fieldtype==='Currency') { + if (field.fieldtype === 'Currency') { value = number_format.format_number(value); } else if (field.fieldtype === 'Text') { @@ -26,7 +26,7 @@ module.exports = { value = moment(value).format(dateFormat.toUpperCase()); } else { - if (value===null || value===undefined) { + if (value === null || value === undefined) { value = ''; } else { value = value + '';