开发者

How to complete login with phonegap and devise (Rails)

I have a rails app that has devise gem installed (with auth_token setup). I'm not sure how to make my jquery mobile app ask for the token and sto开发者_运维技巧re it (in a secure way). Thanks!


i have a similar set up - rails 3 backend with devise as the authentication. i'm using standard jquery, though, on a full browser instead of a mobile, and i have my users log in through normal html forms.

in order to keep my users authenticated and be able to make backbone / jquery ajax calls back to my server, i had to add this to my rails.js file:

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

once i put that in place, i didn't have to worry about authentication anymore.

hope that helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜