Closed Zalasanjay closed 6 years ago
or if i configure my jwt authentication service like
app.configure(authentication({ secret: config.secret }));
app.configure(jwt({service : "cb-plan"}));
then cb-plan service is calling every time if i call other service too.
The /users
or /cb-plan
service has to be registered before calling app.configure()
@daffl i have tried to register /cb-plan
service like
const authentication = require('feathers-authentication');
const jwt = require('@feathersjs/authentication-jwt');
// const mongodb = require('./mongodb');
const app = feathers();
app.configure(authentication({ secret: config.secret }));
app.configure(jwt());
app.service('cb-plan').hooks({
before: {
all: [
authentication.hooks.authenticate(['jwt'])
]
}
});
// Load app configuration
app.configure(configuration(path.join(__dirname, '..')));
before app.configure()
and it is giving an error like
app.service('cb-plan').hooks({
^
TypeError: Cannot read property 'hooks' of undefined
at Object.<anonymous> (/home/software/sanjay/80015/PROJECT/subscription/service/src/app.js:31:23)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/software/sanjay/80015/PROJECT/subscription/service/src/index.js:3:13)
at Module._compile (module.js:643:30)
I'm not seeing where you are calling app.use('cb-plan', <serviceobject>)
which is what has to happen before configuring authentication.
throw new Error(
options.service does not exist.\n\tMake sure you are passing a valid service path or service instance and it is initialized before @feathersjs/authentication-jwt.
); ^Error: options.service does not exist. Make sure you are passing a valid service path or service instance and it is initialized before @feathersjs/authentication-jwt. at new JWTVerifier (/home/software/sanjay/80015/PROJECT/subscription/service/node_modules/@feathersjs/authentication-jwt/lib/verifier.js:11:13) at Function.app.setup (/home/software/sanjay/80015/PROJECT/subscription/service/node_modules/@feathersjs/authentication-jwt/lib/index.js:79:22) at Function.listen (/home/software/sanjay/80015/PROJECT/subscription/service/node_modules/feathers/lib/application.js:157:10) at Function.listen (/home/software/sanjay/80015/PROJECT/subscription/service/node_modules/uberproto/lib/proto.js:30:17) at Object. (/home/software/sanjay/80015/PROJECT/subscription/service/src/index.js:5:20)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)