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:

  1. if user not logged in, make get call default parameters
  2. if user logged in, make get call user.attribute parameter

i want allow user post edit account details (e.g., user.attribute).


how i:

  1. check if user logged in / allow user log in backbone or separate rails site
  2. pull logged-in user's attribute
  3. verify authenticity when posting

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 or post 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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -