How to use the feathers-hooks-common.lowerCase function in feathers-hooks-common

To help you get started, we’ve selected a few feathers-hooks-common examples, based on popular ways it is used in public projects.

github feathersjs-ecosystem / feathers-hooks-common / types / tests.ts View on Github external
isProvider();

// $ExpectType Hook<any, Service<any>>
keep('abc', 'def');

// $ExpectType Hook<any, Service<any>>
keepInArray('array', ['fieldName', 'fieldName']);

// $ExpectType Hook<any, Service<any>>
keepQuery('name', 'address.city');

// $ExpectType Hook<any, Service<any>>
keepQueryInArray('array', ['fieldName', 'fieldName']);

// $ExpectType Hook<any, Service<any>>
lowerCase('email', 'username', 'div.dept');

// $ExpectType Params
makeCallingParams(
    context1,
    { id: { $in: [1, 2, 3] } },
    'user',
    { _populate: false, mongoose: {} }
);

// tslint:disable-next-line
class ObjId {
    // tslint:disable-next-line
    constructor(id?: string | number) { }
}

// $ExpectType Hook<any, Service<any>>
github Human-Connection / API / server / authentication.js View on Github external
module.exports = function () {
  const app = this;
  const config = app.get('authentication');

  // Set up authentication with the secret
  app.configure(authentication(config));
  app.configure(jwt());
  app.configure(local(config.local));

  // The `authentication` service is used to create a JWT.
  // The before `create` hook registers strategies that can be used
  // to create a new valid JWT (e.g. local or oauth2)
  app.service('authentication').hooks({
    before: {
      create: [
        lowerCase('email', 'username'),
        authentication.hooks.authenticate(config.strategies)
      ],
      remove: [
        authentication.hooks.authenticate('jwt')
      ]
    }
  });

  app.on('login', (result, meta) => {
    try {
      if (meta.connection && meta.connection.user) {
        // update last active timestamp on loggedin user
        app.service('users').patch(meta.connection.user, {
          lastActiveAt: new Date()
        });
      }
github Human-Connection / API / server / services / users / users.hooks.js View on Github external
saveRemoteImages(['avatar', 'coverImg'])
    ],
    update: [
      ...restrict,
      hashPassword(),
      disableMultiItemChange(),
      lowerCase('email', 'username'),
      when(isProvider('external'),
        restrictUserRole()
      ),
      saveRemoteImages(['avatar', 'coverImg'])
    ],
    patch: [
      ...restrict,
      disableMultiItemChange(),
      lowerCase('email', 'username'),
      // Only set slug once
      when(
        hook => {
          return hook.params && hook.params.user && !hook.params.user.slug;
        },
        createSlug({ field: 'name' })
      ),
      when(isProvider('external'),
        restrictUserRole()
      ),
      saveRemoteImages(['avatar', 'coverImg'])
    ],
    remove: [
      ...restrict,
      disableMultiItemChange(),
      removeAllRelatedUserData()
github codingfriend1 / Feathers-Vue / src / services / user / hooks / index.js View on Github external
auth.populateUser(),
    auth.restrictToAuthenticated(),
    globalHooks.isEnabled(),
    globalHooks.hasPermission('manageUsers')
  ],
  get: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    globalHooks.isEnabled(),
    globalHooks.hasPermission('manageUsers')
    // auth.restrictToOwner({ ownerField: '_id' })
  ],
  create: [
    auth.hashPassword(),
    common.lowerCase('email'),
    verifyHooks.addVerification(),
    globalHooks.setDefaultRole(),
    globalHooks.setFirstUserToRole({role: 'admin'})
  ],
  update: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    globalHooks.isEnabled(),
    globalHooks.hasPermissionOrRestrictChanges('manageUsers', {
      restrictOn: ['role', 'isEnabled']
    }),
    globalHooks.preventDisabledAdmin()
  ],
  patch: [
    auth.verifyToken(),
github Human-Connection / API / server / services / invites / invites.hooks.js View on Github external
const isAdmin = require('../../hooks/is-admin');

const sendInviteEmail = require('./hooks/send-invite-email');
const restrictAPIToAdmin = when(isProvider('external'),
  isAdmin()
);

module.exports = {
  before: {
    all: [
      restrictAPIToAdmin
    ],
    find: [],
    get: [],
    create: [
      lowerCase('email', 'username')
    ],
    update: [],
    patch: [],
    remove: []
  },

  after: {
    all: [],
    find: [],
    get: [],
    create: [
      sendInviteEmail()
    ],
    update: [],
    patch: [],
    remove: []