jquery - How to check user logged in and make Backbone get/post to Rails backend? (+Devise) -
i have rails backend uses devise, , decoupled backbone frontend on separate site.
i'd have backbone make get
calls separate rails server items resource. based on:
- if user not logged in, make
get
call default parameters - if user logged in, make
get
calluser.attribute
parameter
i want allow user post
edit account details (e.g., user.attribute
).
how i:
- check if user logged in / allow user log in backbone or separate rails site
- pull logged-in user's attribute
- verify authenticity when
post
ing
tl;dr how share session between devise , backbone? how make calls using session? session sharing right structure?
i've seen this answer , understanding far is:
- backbone passes user's login information in
get
devise/signin
- rails sends session cookie , other stuff somehow save in backbone somewhere
- each time backbone makes
get
orpost
calls, use session cookie , other stuff? , rails/devise verifies somehow
thanks in advance -
it's best front end assume user logged in, make request, , server fail request 401, 403, or similar response code, indicating front end users not authenticated. front end should make whatever calls necessary authenticate user, , reissue original request(s) user appropriate.
Comments
Post a Comment