feathersjs-ecosystem / feathers-authentication-management

Adds sign up verification, forgotten password reset, and other capabilities to local feathers-authentication
https://feathers-a-m.netlify.app/
MIT License
246 stars 98 forks source link

using verifyHooks.addVerification() #128

Closed OnePunchMan007 closed 4 years ago

OnePunchMan007 commented 4 years ago

Using verifyHooks.addVerification() with "feathers-authentication-management": "^2.0.1", and "@feathersjs/authentication": "^4.3.0",

i have got : GeneralError: The "size" argument must be of type number. Received type undefined

user hook :

const { authenticate } = require('@feathersjs/authentication').hooks; const verifyHooks = require('feathers-authentication-management').hooks; const accountService = require('../authManagement/notifier'); const commonHooks = require('feathers-hooks-common');

const { hashPassword, protect } = require('@feathersjs/authentication-local').hooks;

module.exports = { before: { all: [], find: [authenticate('jwt')], get: [authenticate('jwt')], create: [hashPassword('userPassword'), verifyHooks.addVerification()], update: [ commonHooks.disallow('external'), hashPassword('userPassword'), authenticate('jwt') ], patch: [ commonHooks.iff( commonHooks.isProvider('external'), commonHooks.preventChanges(true, [ 'userEmail', 'isVerified', 'verifyToken', 'verifyShortToken', 'verifyExpires', 'verifyChanges', 'resetToken', 'resetShortToken', 'resetExpires' ]) ), hashPassword('userPassword'), authenticate('jwt') ], remove: [authenticate('jwt')] },

after: { all: [

  protect('userPassword')
],
find: [],
get: [],
create: [
  context => {
    accountService(context.app).notifier(
      'resendVerifySignup',
      context.result
    );
  },
  verifyHooks.removeVerification()
],
update: [],
patch: [],
remove: []

},

error: { all: [], find: [], get: [], create: [], update: [], patch: [], remove: [] } };

service : // Initializes the authmanagement service on path /authmanagement

const authMan = require('feathers-authentication-management'); // initialement feathers-authentication-management or authentication-local-management-v4 const { Authmanagement } = require('./authmanagement.class'); const hooks = require('./authmanagement.hooks'); const notifier = require('./notifier');

module.exports = function(app) { // Initialize our service with any options it requires app.configure( authMan({ service: 'users', notifier, identifyUserProps: ['userEmail'] }) ); app.use('/authManagement', new Authmanagement(app)); // Get our initialized service so that we can register hooks const service = app.service('authManagement');

service.hooks(hooks); };

OnePunchMan007 commented 4 years ago

my bad service : // Initializes the authmanagement service on path /authmanagement

const authMan = require('feathers-authentication-management'); // initialement feathers-authentication-management or authentication-local-management-v4 const { Authmanagement } = require('./authmanagement.class'); const hooks = require('./authmanagement.hooks'); const notifier = require('./notifier');

module.exports = function(app) { // Initialize our service with any options it requires app.use('/authManagement', new Authmanagement(app));

app.configure( authMan({ service: 'users', notifier, identifyUserProps: ['userEmail'] }) );

// Get our initialized service so that we can register hooks const service = app.service('authManagement');

service.hooks(hooks); };