Devise choose subdomain for user
I have to create some type user friendly way of getting the user to login to there location.
Using devise for authentication. Company has subdomain field. Currently, if user signs in root, they also have to signin to the subdomain too.
Ideally, a user gets to the login screen and after they sign in, I could redirect them to the companies index controller. When they select a company, it redirects them to that companies subdomain and logs them in there.
Is there a way to store the login credentials and pass them to the subdomain after they select the subdomain?
Edit -
class Company < ActiveRecord::Base
attr_accessible :name, :subdomain, :parent_id
end
class CompaniesControlle开发者_运维问答r < ApplicationController
def show
@company = Company.find_by_subdomain!(request.subdomain)
end
end
User such as District Manager can login and manage many companies. An employee can only login to a single company.
Being done so Manager can see what the other stores / companies are doing, but not employees.
I answered similar on this SO post... You'll want your cookies to be valid on all domains
Yourapp::Application.config.session_store :cookie_store, :key => '_yourapp_session', :domain=>:all
精彩评论