2017-11-14 11:11:22 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Lifecycle callbacks for the `User` model.
|
|
|
|
*/
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
|
|
// Before saving a value.
|
|
|
|
// Fired before an `insert` or `update` query.
|
|
|
|
// beforeSave: function (next) {
|
|
|
|
// // Use `this` to get your current object
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// After saving a value.
|
|
|
|
// Fired after an `insert` or `update` query.
|
|
|
|
// afterSave: function (doc, next) {
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// Before fetching all values.
|
|
|
|
// Fired before a `fetchAll` operation.
|
|
|
|
// beforeFetchAll: function (next) {
|
|
|
|
// // Use `this` to get your current object
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// After fetching all values.
|
|
|
|
// Fired after a `fetchAll` operation.
|
|
|
|
// afterFetchAll: function (doc, next) {
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// Fired before a `fetch` operation.
|
|
|
|
// beforeFetch: function (next) {
|
|
|
|
// // Use `this` to get your current object
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// After fetching a value.
|
|
|
|
// Fired after a `fetch` operation.
|
|
|
|
// afterFetch: function (doc, next) {
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// Before creating a value.
|
|
|
|
// Fired before `insert` query.
|
2017-11-16 14:12:03 +01:00
|
|
|
beforeCreate: async function (next) {
|
|
|
|
// Use `this` to get your current object
|
|
|
|
this.password = await strapi.plugins['users-permissions'].services.user.hashPassword(this);
|
|
|
|
next();
|
|
|
|
},
|
2017-11-14 11:11:22 +01:00
|
|
|
|
|
|
|
// After creating a value.
|
|
|
|
// Fired after `insert` query.
|
|
|
|
// afterCreate: function (doc, next) {
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// Before updating a value.
|
|
|
|
// Fired before an `update` query.
|
|
|
|
// beforeUpdate: function (next) {
|
|
|
|
// // Use `this` to get your current object
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// After updating a value.
|
|
|
|
// Fired after an `update` query.
|
|
|
|
// afterUpdate: function (doc, next) {
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// Before destroying a value.
|
|
|
|
// Fired before a `delete` query.
|
|
|
|
// beforeDestroy: function (next) {
|
|
|
|
// // Use `this` to get your current object
|
|
|
|
// next();
|
|
|
|
// },
|
|
|
|
|
|
|
|
// After destroying a value.
|
|
|
|
// Fired after a `delete` query.
|
|
|
|
// afterDestroy: function (doc, next) {
|
|
|
|
// next();
|
|
|
|
// }
|
|
|
|
};
|