Working with state in Backbone.js & logging in a user

和自甴很熟 提交于 2019-12-05 21:25:15

if access to your backend REST API is protected server side and it wouldn't allow to access any user data when i'd for example stop the execution of code from developer tools and edit model's data (like set the state.loggedIn to true and set some user's i'd like to steal data from ID as my own). You should probably have also cookie session stored and maybe CSRF protection in to prevent cross site request forgery.

But basically backend should redirect user to login page whenever user isn't really logged in or his session expired.

You can also use backbone async before and after filters to solve such problems.

I made a lib to handle logins and session stuff for us.

https://github.com/chirag04/backbone-async-route-filter

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