We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am using Feathers.js for the backend.
This is the original response from POST /authentication
{ "accessToken": "XXXXX", "authentication": { "strategy": "local", "accessToken": "XXXXX", "payload": { "iat": 1616402936, "exp": 1616489336, "aud": "https://yourdomain.com", "iss": "feathers", "sub": "c15ef318-68fc-471c-9710-52f14d87abda", "jti": "57d103e1-c81b-4fc6-8bbe-952b74aaf8e3" } }, "user": { "id": "c15ef320-68fc-471c-9710-52f14d87ccda", "email": "abc.abc@abc.com", } }
I want to discard the accessToken field from the response, so I modified authentication.js as:
accessToken
authentication.js
const { AuthenticationService, JWTStrategy } = require('@feathersjs/authentication'); const { LocalStrategy } = require('@feathersjs/authentication-local'); const { expressOauth } = require('@feathersjs/authentication-oauth'); const { discard, iff, isProvider, lowerCase } = require('feathers-hooks-common') module.exports = app => { const authentication = new AuthenticationService(app); authentication.register('jwt', new JWTStrategy()); authentication.register('local', new LocalStrategy()); authentication.hooks = { before: { create: [lowerCase('email')], update: [lowerCase('email')], patch: [lowerCase('email')], }, after: { create: [discard('accessToken')] } }; app.use('/authentication', authentication); app.configure(expressOauth()); };
But nothing changes after I've changed the code to the above one.
What is wrong here?
The text was updated successfully, but these errors were encountered:
The correct way to register hooks is app.service('authentication').hooks():
app.service('authentication').hooks()
module.exports = app => { const authentication = new AuthenticationService(app); authentication.register('jwt', new JWTStrategy()); authentication.register('local', new LocalStrategy()); app.use('/authentication', authentication); app.service('/authentication').hooks({ before: { create: [lowerCase('email')], update: [lowerCase('email')], patch: [lowerCase('email')], }, after: { create: [discard('accessToken')] } }); app.configure(expressOauth()); };
Sorry, something went wrong.
The correct way to register hooks is app.service('authentication').hooks(): module.exports = app => { const authentication = new AuthenticationService(app); authentication.register('jwt', new JWTStrategy()); authentication.register('local', new LocalStrategy()); app.use('/authentication', authentication); app.service('/authentication').hooks({ before: { create: [lowerCase('email')], update: [lowerCase('email')], patch: [lowerCase('email')], }, after: { create: [discard('accessToken')] } }); app.configure(expressOauth()); };
/server/node_modules/@feathersjs/authentication/lib/service.js:141
this.hooks({
^
TypeError: this.hooks is not a function
No branches or pull requests
I am using Feathers.js for the backend.
This is the original response from POST /authentication
I want to discard the
accessToken
field from the response, so I modifiedauthentication.js
as:But nothing changes after I've changed the code to the above one.
What is wrong here?
The text was updated successfully, but these errors were encountered: