jamesplease / gistbook

[No longer hosted] A place to write about technical subjects on the web.
MIT License
88 stars 16 forks source link

Don't add logout to history #373

Open jamesplease opened 9 years ago

jamesplease commented 9 years ago

It breaks the back button since logout just redirects you home.

jamesplease commented 9 years ago

This depends on https://github.com/jmeas/backbone.intercept/issues/13

jamiebuilds commented 9 years ago

Why is logout a route?

jamesplease commented 9 years ago

For the same reason there's any other route? It's an action tied to a URI. I think this is a pretty common pattern.

Github and Twitter, for instance, use a form that posts to /logout to log the user out.

jamiebuilds commented 9 years ago

http://lostechies.com/derickbailey/2011/08/03/stop-using-backbone-as-if-it-were-a-stateless-web-server/

Outlines the reasoning really well.

jamesplease commented 9 years ago

It's certainly possible to do this without the router, but I prefer going through the router in this situation. There is actually a /logout route on the server, and, by chance, the same functionality can be achieved on the client. For this reason, there should be a client-side route that describes that functionality, I think.

Further, I much prefer not writing it to history than the alternatives. One alternative is simply not having any client-side route at all. It would just be a button that magically logs you out. I dislike this because it just seems weird. Robots, for instance, would not be able to make any sense of it.

Another option would be actually POSTing to the server's /logout route, which would be an unnecessary HTTP request.