Login with subdomain field on main site

82 views
Skip to first unread message

coneybeare

unread,
Feb 12, 2013, 3:00:14 PM2/12/13
to plataforma...@googlegroups.com
I have subdomain login setup property such that username/password logs in on the domain test.foobar.com.

I am trying to allow login from just foobar.com that will redirect to the subdomain and be logged in, so I have added a subdomain field to the login form on foobar.com/login.

I have overridden the SessionsController and am able to find the subdomain properly from this param, then am able to login the user correctly:

    if subdomain_account
      params[:user][:account_id] = subdomain_account.id
      self.resource = warden.authenticate!(auth_options)
      set_flash_message(:notice, :signed_in) if is_navigational_format?
      sign_in(resource_name, resource)
      respond_with resource, :location => root_url(:subdomain => subdomain_account.subdomain)
    else
      render :global_new
    end

The user appears to be logged in and there are no exceptions thrown, but on the respond_with redirect to test.foobar.com, the login appears to be lost, that is, it is not reading from the cookie properly.

I have my session store :domain value set to :domain => '.foobar.com', but devise is not recognizing that foobar.com has already logged in the user. What am I doing wrong here?

Dennis Castro

unread,
Feb 27, 2013, 8:14:24 PM2/27/13
to plataforma...@googlegroups.com
hi Group.

I have the same problem
I have two  apps

App1 with Devise.. works perfect!
App2 Without model User. 


App1 set:
App1::Application.config.session_store :cookie_store, :key => '_app1_session'
I also tested setting domiain '.app1.com'

App2 set:
App2::Application.config.session_store :cookie_store, :key => '_app1_session',  domain: :all and also tested with '.app1.com'

I have many tests... but never the app2 sign in.. and sometimes when I come back to App1, lose the app1 session

What is the problem?


Dennis

Alejandro Wainzinger

unread,
Mar 6, 2013, 3:58:21 AM3/6/13
to plataforma...@googlegroups.com
Having a similar issue. From what I can tell, it makes a session and associates it with foobar.com, but when you go to test.foobar.com, it looks for a session associated with test.foobar.com, doesn't find it, and fails.

I was thinking if there's a way to "trick" Warden into associating with a different domain (i.e. test.foobar.com) by setting a Rack variable or something, but not sure which we would need to set.

Dennis Castro

unread,
Mar 6, 2013, 9:27:03 AM3/6/13
to plataforma...@googlegroups.com
I still have the problem...


Dennis

--
 
---
You received this message because you are subscribed to the Google Groups "Devise" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages