Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails Devise: Login from a different domain

I have search everywhere but I can't seem to find the right answer for my problem. So here goes.

I have 2 domains....

http://www.mywebsite.com/ and http://app.mywebsite.com/

Those two domains are in two different rails apps.

Devise resides in app.mywebsite.com. I have a login/signup form in www.mywebsite.com that will connect to app.website.com. How do I do this?

like image 763
Eralph Avatar asked May 10 '13 05:05

Eralph


1 Answers

You need to share the model devise session

Try this

Just modify the config/initializers/session_store.rb

Yourapp::Application.config.session_store :cookie_store, key: '_Yourapp_session', :domain => '.mywebsite.com'

It works on my applications.

UPDATE

For my answer above, I only tried in one application but different schema, and it works.

Devise model not works if you not put gem devise. :D

If different application, you need www.mywebsite.com access to database of mywebsite.com Or you can use SSO for your applications.

I think you need this :

  1. Multiple Applications with Devise, Omniauth and Single Sign On
  2. sso-devise-omniauth-provider

Some similar questions :

  1. Single logon with different applications approach ruby on rails
  2. How to pass devise sign_in information into different application with rails
  3. OmniAuth Single Sign On with Devise
like image 78
rails_id Avatar answered Oct 23 '22 21:10

rails_id