How to use feathers-authentication - 10 common examples

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eddyystop / feathers-starter-react-redux-login-roles / server / services / index.js View on Github external
app.configure(verifyReset);
  app.configure(user);
  app.configure(message);

  // get client config file
  app.use('/config', {
    get() {
      return Promise.resolve(config.clientConfig);
    },
  });

  // create log entry
  app.use('/logs', {
    before: {
      create: [
        tryHook(auth.verifyToken()),
        tryHook(auth.populateUser()),
      ],
    },
    create({ level, msg, payload }, params) {
      const paramsUser = params.user;

      if (paramsUser && (paramsUser.email || paramsUser.username)) {
        payload.user = payload.user || {};

        if (paramsUser.email) {
          payload.user.email = paramsUser.email;
        }
        if (paramsUser.username) {
          payload.user.username = paramsUser.username;
        }
      }
github eddyystop / feathers-hooks-utils / test / restrictToAuthenticated_spec.js View on Github external
it('returns expected hooks', () => {
    assert.equal(restrictToAuthenticated[0].toString(), auth.verifyToken().toString());
    assert.equal(restrictToAuthenticated[1].toString(), auth.populateUser().toString());
    assert.equal(restrictToAuthenticated[2].toString(),
      auth.restrictToAuthenticated().toString());
  });
});
github eddyystop / feathers-hooks-utils / test / restrictToAuthenticated_spec.js View on Github external
it('returns expected hooks', () => {
    assert.equal(restrictToAuthenticated[0].toString(), auth.verifyToken().toString());
    assert.equal(restrictToAuthenticated[1].toString(), auth.populateUser().toString());
    assert.equal(restrictToAuthenticated[2].toString(),
      auth.restrictToAuthenticated().toString());
  });
});
github eddyystop / feathers-hooks-utils / test / restrictToAuthenticated_spec.js View on Github external
it('returns expected hooks', () => {
    assert.equal(restrictToAuthenticated[0].toString(), auth.verifyToken().toString());
    assert.equal(restrictToAuthenticated[1].toString(), auth.populateUser().toString());
    assert.equal(restrictToAuthenticated[2].toString(),
      auth.restrictToAuthenticated().toString());
  });
});
github primozs / feathers-react-bojler / server / services / user / hooks / index.js View on Github external
const globalHooks = require('../../../hooks');
const hooks = require('feathers-hooks');
const auth = require('feathers-authentication').hooks;
const gravatar = require('./gravatar');

exports.before = {
  all: [],
  find: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated()
  ],
  get: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    auth.restrictToOwner({ ownerField: 'id' })
  ],
  create: [
    auth.hashPassword(), gravatar()
  ],
  update: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
github primozs / feathers-react-bojler / server / services / message / hooks / index.js View on Github external
const globalHooks = require('../../../hooks');
const hooks = require('feathers-hooks');
const auth = require('feathers-authentication').hooks;
const process = require('./process');
const restrictToSender = require('./restrict-to-sender');

const populateSender = hooks.populate('sentBy', {
  service: 'users',
  field: 'id'
});

exports.before = {
  all: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated()
  ],
  find: [],
  get: [],
  create: [process()],
  update: [hooks.remove('sentBy'), restrictToSender()],
  patch: [hooks.remove('sentBy'), restrictToSender()],
  remove: [restrictToSender()]
};

exports.after = {
  all: [],
  find: [populateSender],
  get: [populateSender],
  create: [populateSender],
github codingfriend1 / meanbase / src / services / image-uploads / hooks / index.js View on Github external
'use strict';

import resize from './resize';

const globalHooks = require('../../../hooks');
const hooks = require('feathers-hooks');
const auth = require('feathers-authentication').hooks;
const dauria = require('dauria');

const permissionName = 'manageMedia';

exports.before = {
  create: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    globalHooks.attachPermissions(),
    globalHooks.isEnabled(),
    globalHooks.hasPermission(permissionName),
    resize()
  ]
};

exports.after = {
  all: [],
  find: [],
  get: [],
  create: [

  ],
github codingfriend1 / meanbase / src / services / images / hooks / index.js View on Github external
const globalHooks = require('../../../hooks');
const hooks = require('feathers-hooks');
const auth = require('feathers-authentication').hooks;

const permissionName = 'manageMedia';

exports.before = {
  all: [],
  find: [

  ],
  get: [

  ],
  create: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    globalHooks.attachPermissions(),
    globalHooks.isEnabled(),
    globalHooks.hasPermission(permissionName)
  ],
  update: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    globalHooks.attachPermissions(),
    globalHooks.isEnabled(),
    globalHooks.hasPermission(permissionName)
  ],
  patch: [
    globalHooks.allowUpsert(),
github codingfriend1 / meanbase / src / services / ban / hooks / index.js View on Github external
'use strict';

const globalHooks = require('../../../hooks');
const hooks = require('feathers-hooks');
const auth = require('feathers-authentication').hooks;

const permissionName = 'moderateComments';

exports.before = {
  all: [],
  find: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    globalHooks.attachPermissions(),
    globalHooks.isEnabled(),
    globalHooks.hasPermission(permissionName)
  ],
  get: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    globalHooks.attachPermissions(),
    globalHooks.hasPermission(permissionName)
  ],
  create: [
    auth.verifyToken(),
    auth.populateUser(),
github primozs / feathers-react-bojler / server / services / user / hooks / index.js View on Github external
const globalHooks = require('../../../hooks');
const hooks = require('feathers-hooks');
const auth = require('feathers-authentication').hooks;
const gravatar = require('./gravatar');

exports.before = {
  all: [],
  find: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated()
  ],
  get: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    auth.restrictToOwner({ ownerField: 'id' })
  ],
  create: [
    auth.hashPassword(), gravatar()
  ],
  update: [
    auth.verifyToken(),
    auth.populateUser(),
    auth.restrictToAuthenticated(),
    auth.restrictToOwner({ ownerField: 'id' })

feathers-authentication

Add Authentication to your FeathersJS app.

MIT
Latest version published 6 years ago

Package Health Score

45 / 100
Full package analysis