Commit Graph

10 Commits

Author SHA1 Message Date
Will Vincent
fd621ca5ae fix(trait): syntax error (#37) 2019-01-21 10:04:24 +01:00
Romain Lanz
8e46d02ed1
feat: add NoTimestamp trait + ConvertEmptyStringsToNull middleware (#30)
Hey! 👋 

This PR add some middleware and traits by default.

**Middleware**:

- `AllowGuestOnly` throws an exception if you are authenticated.
- `ConvertEmptyStringsToNull` converts empty strings in the request body to `null`

**Trait**:

- `NoTimestamp` removes the need for `created_at` and `updated_at` fields.
- `FormatDate` formats the date following a convention.

**FormatDate**

The convention is:
- Ends with `_at` => DateTime
- Ends with `_on` => Date

You can change the format you use in your UI with two getters.

```js
class MyModel extends Model {
  static get formatDate () { return 'DD.MM.YYYY' }
  static get formatDateTime () { return 'DD.MM.YYYY HH:mm' }
}
```

You can also directly change default values inside the Trait since it is a user Trait and not defined in the core.

<hr>

If this is merged, I'll provide the same PR to the `API` blueprint.
2019-01-02 10:10:56 +01:00
Romain Lanz
b38ea8d773
feat(intellisense): add type comments 2018-09-15 09:37:07 +02:00
Romain Lanz
0b79d48d21
fix(User): use beforeSave hook 2018-06-10 22:33:30 +02:00
Roman
ba18e2d712 feat(hook): Verify status before hashing
To prevent double-hashing on udpate
2018-06-05 17:53:20 +05:30
Romain Lanz
3735f11f91 chore(hook): move beforeCreate hook to user model (#16) 2018-06-05 17:53:20 +05:30
Michael Raypold
ed144ae039 doc(user-model): fix typo in addHook 2018-02-09 17:05:39 +05:30
Harminder Virk
eb9afd9377 fix(hooks): use beforeCreate over beforeSave 2018-02-09 17:05:39 +05:30
Stephen Afam-Osemene
c19c0d0880 fix(hook): use beforeSave over beforeCreate
Changed the hook from `beforeCreate` to `beforeSave`
With `beforeCreate` the password will not be hashed if it is changed later
2017-10-24 11:48:18 +05:30
Harminder Virk
991657c76b feat(*) initial commit 2017-08-20 22:39:25 +05:30