Logout using FeathersJS REST API

狂风中的少年 提交于 2021-01-07 01:53:12

问题


Using freshly generated FeathersJS application (local auth), I am doing following REST api calls with following behaviour:

  1. GET /users - it FAILS with not-authorized
  2. POST /authentication with username and password - successful
  3. GET /users - it SUCCEEDS and returns list of users
  4. DELETE /authentication - returns auth object, no error messages (and on server side logout event is generated)
  5. GET /users - it SUCCEEDS and returns list of users

expected result from my side is that on step 5 I would get not-authorized error, as JWT token would be expired after logout on server side.

what am I doing wrong? how can I logout user properly using just REST api, so token would be invalidated? or authentication is meant to be used only in conjunction with FeathersJS client libraries?

p.s. I am trying out FeathersJS as a potential solution for backend REST API for my Flutter app. Hence I am interested only in server side implementation of FeathersJS.


回答1:


FeathersJS is stateless. So, in your client, just set your access token to null.




回答2:


I use socketio client. I normally logout users by calling app.logout() then clearing the localStorage item "feathers-jwt" just to be sure. follow this https://docs.feathersjs.com/api/client/rest.html#feathersjs-rest-client to read on how you can configure a REST client. hope it helps



来源:https://stackoverflow.com/questions/59005615/logout-using-feathersjs-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!