farmOS / farmOS.js

A JavaScript library for working with farmOS data structures and interacting with farmOS servers.
MIT License
15 stars 13 forks source link

No response returned when logout endpoint is called #9

Closed alexadamsmith closed 4 years ago

alexadamsmith commented 5 years ago

When the logout endpoint is called, the server does not return response data. In consequence, farmOS.js does not return a response at all when farmOS.logout() is called, though the function appears to work.

@jgaehring suggested returning the response code whenever res.data is null.

jgaehring commented 5 years ago

Thanks, @alexadamsmith, this is a great point to consider!

For reference, this is the schema for the response object provided by axios: https://github.com/axios/axios#response-schema

So we could do a few different things with that: we could just return res.status or res.statusText; or we could return the entire response object. That last option seems best to me, because it provides the user with the most info for debugging if something went wrong or unexpectedly, and because it seems like the best generic behavior for any instance where res.data === undefined.

@paul121, does farmOS.py have a .logout() method, and if so, does it supply any specific data in the response?

paul121 commented 5 years ago

hmmm interesting. farmOS.py doesn't have s .logout() method.

My view on this is that users would make a new instance of the Farm object if they are going to connect to another server. I'm not sure of the need for logging out in Python...but totally see it in the client app!

I guess it comes down to the Session, is it best practice to close that? is that all the farmOS logout endpoint does?

jgaehring commented 5 years ago

I guess it comes down to the Session, is it best practice to close that? is that all the farmOS logout endpoint does?

Basically. We need to be able to call the endpoint /user/logout in order to clear the HttpOnly cookie, which cannot be accessed via JavaScript. So I can totally see why this would not be necessary for uses outside of the browser.