Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User auth example in Rails 3, using Devise, OmniAuth, Mongoid, and JSON responses

I have integrated Devise and OmniAuth with my Mongoid ORM setup using the following examples:

https://github.com/plataformatec/devise/wiki/Example-Applications

My client code is mostly JavaScript (ExtJS) and relies on JSON for all of the communication. I use no Rails templates. I am looking to build a multi-provider authentication model, primarily using user/pass, Facebook, and Twitter. I am having difficulty putting together the full User authentication flow with respect to my application stack.

I am looking for an example that uses JSON responses to the standard authentication actions, instead of redirects, and provides an integration with OmniAuth that uses Mongoid. In addition to the above examples, I have gone through Ryan Bates' Railscasts on Devise and OmniAuth. Every example I have worked through so far have either been ActiveRecord, or Rails template oriented. Any pointers are appreciated!

like image 259
Mike Clymer Avatar asked Dec 23 '10 23:12

Mike Clymer


1 Answers

This (https://github.com/fertapric/rails3-mongoid-devise-omniauth) is a good example app for getting set up with rails 3, devise, omniauth and mongoid, and a tutorial to go along with it here: https://github.com/fortuity/rails3-mongoid-devise/wiki/Tutorial-(Walkthrough)

Then you'll need to override the user sessions controller to provide the correct json responses for your app, there is a good example here: https://gist.github.com/733647 and here: http://groups.google.com/group/plataformatec-devise/browse_thread/thread/daa3332b3c4a1b4b

Hope this helps

like image 150
Andrew Nesbitt Avatar answered Oct 04 '22 06:10

Andrew Nesbitt