How to fill in a login using a telephone conversation and create (Rails)

I have a rails application in which gem gem is installed (with auth_token setting). I'm not sure how to get the jQuery mobile app to request a token and store it (in a safe way). Thanks!

+6
source share
1 answer

I have a similar setup - rails 3 backend with design as authentication. I use standard jquery, however, in a fully functional browser instead of a mobile one, and I have my users included in regular html forms.

so that my users are authenticated and able to make backjone / jquery ajax callbacks on my server, I had to add this to the rails.js file:

$.ajaxSetup({ beforeSend: function(xhr) { xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content')); } }); 

As soon as I put this in place, I no longer had to worry about authentication.

hope that helps

+1
source

Source: https://habr.com/ru/post/898170/


All Articles