module.exports = function(user) {

  user.beforeCreate = function(next, user) {
    if (user.username == undefined) {
      user.username = user.email;
    }
    user.status = 'created';
    user.created = Date.now();
    next();
  };


};

module.exports = function (user) {

  // Set the username to the users email address by default.
  user.observe('before save', function setDefaultUsername(ctx, next) {
    if (ctx.instance) {
      if (ctx.instance.username === undefined) {
        ctx.instance.username = ctx.instance.email;
      }
      ctx.instance.status = 'created';
      ctx.instance.created = Date.now();
      ctx.instance.confirmPassword = null;
    }
    next();
  });

};

Replace deprecated beforeCreate with 'before save' observer
Replace deprecated beforeCreate with 'before save' observer
