akveo / ngx-admin-bundle-support

Support repository for ngx-admin backend bundles with issues tracking, instructions and code samples
58 stars 32 forks source link

getting jwt errors #10

Closed worldfellow closed 4 years ago

worldfellow commented 4 years ago

Hi after implementing chat via socket io i am getting error of 401 unauthorized even for login so my question here is there a way to temporarily disable jwt in the backend also is there a way to test login via postman i want to test router.post('/login', (req, res) => { passport.authenticate('local', { session: false }, (err, user) => { this on postman

401

daveboulden commented 4 years ago

For the usual REST interface, you can edit the app.js file of the backend project, you can disable the JWT by removing the "auth" reference from the appropriate call to use your controller with a specific route:

// routes for common controllers
app.use(`${root}/auth`, authController);
app.use(`${root}/users`, auth, userController);
app.use(`${root}/nojwtitems`, nojwtitemsController);   <------- omit 2nd parameter "auth" to disable JWT
app.use(`${root}/settings`, auth, settingsController);

Not sure if it is different for socket io.

valentinkononov commented 4 years ago

Hi! for Java, .NET, .NET Core or Nest.JS the easiest way to test API and authentication is to do it in Swagger, which is already setup in the bundle. for pure node.js you need to setup token in headers of request in postman.

@daveboulden is correct, to disable authentication for any of the controllers, just skip 'auth' parameter for app.use call. like this: app.use('route', noJwtController)