feathersjs-ecosystem/feathers-authentication-management

verifyHooks.addVerification erroring out

bibhashSi opened this issue · 2 comments

verifyHooks.addVerification failing with error :

{ "name": "BadRequest", "message": "The \"size\" argument must be of type number. Received undefined", "code": 400, "className": "bad-request", "data": {}, "errors": [ "The \"size\" argument must be of type number. Received undefined" ] }

user hook

before: {
    all: [],
    find: [authenticate("jwt"), CheckPermissions({ roles: ["admin"] })],
    get: [authenticate("jwt"), addUserIdFilter()],
    create: [
      hashPassword("password"),
      verifyHooks.addVerification(),
     
      addPushNotificationId(),
      addUserRole()
    ],
    update: [
     hashPassword("password"),
    authenticate("jwt")
    ],
    patch: [
      restrictPatchParams(),
      validatePatchParams(),
       hashPassword("password"),
    authenticate("jwt")
    ],
    remove: [   authenticate("jwt")]
  },
  after: {
    all: [
   
    ],
    find: [],
    get: [],
    create: [
      (context: HookContext) => {
        accountService(context.app).notifier('resendVerifySignup', context.result)
      },
      verifyHooks.removeVerification()
    ],
    update: [],
    patch: [],
    remove: []
  }

notifier :

import { Application } from "../../declarations"
import { SERVICE_ENDPOINTS } from "../../constants"
module.exports = function (app: Application) {
    function getLink(type: string, hash: string) {
        const url = 'http://localhost:3030/' + type + '?token=' + hash
        return url
    }
    function sendEmail(email: any) {
        console.log(email);
        return app.service('mailer').create(email).then(function (result) {
            console.log('Sent email', result)
        }).catch(err => {
            console.log('Error sending email', err)
        })
    }
    return {
        notifier: async function (type: string, user: any, notifierOptions: any) {
            let tokenLink
            let email
            switch (type) {
                case 'resendVerifySignup': //sending the user the verification email
                    return app.service(SERVICE_ENDPOINTS.SEND_VERIFICATION_LINK).create({
                        email: user.email
                    })
                case 'verifySignup': // confirming verification
                    tokenLink = getLink('verify', user.verifyToken)
                    console.log(user.verifyToken)
                    email = {
                        from: process.env.FROM_EMAIL,
                        to: user.email,
                        subject: 'Confirm Signup',
                        html: 'Thanks for verifying your email'
                    }
                    return sendEmail(email)
       
                default:
                    break
            }
        }
    }
}

feathers-authentication-management - v3.0.0
tutorial - article i am following

Cannot find any place where this error can be raised b the module itself. Could it be related to token generation here ? Meaning options are not correctly provided.

Please share the way you initialize the module and import the notifier as people sometimes wrongly understand the cited tutorial, see #120 (comment).

Closing because of inactivity.