2010-07-28 00:42:33 +00:00
|
|
|
module Admin
|
|
|
|
class CrossDomainSessionsController < BaseController
|
|
|
|
|
2010-09-21 11:16:39 +00:00
|
|
|
layout '/admin/layouts/box'
|
2010-07-28 00:42:33 +00:00
|
|
|
|
|
|
|
skip_before_filter :verify_authenticity_token
|
|
|
|
|
|
|
|
skip_before_filter :validate_site_membership
|
|
|
|
|
|
|
|
skip_before_filter :set_locale, :only => :create
|
|
|
|
|
|
|
|
before_filter :authenticate_admin!, :only => :new
|
|
|
|
|
|
|
|
def new
|
2010-07-28 10:17:56 +00:00
|
|
|
if site = current_admin.sites.detect { |s| s._id.to_s == params[:target_id] }
|
|
|
|
@target = site.domains_without_subdomain.first || site.domains_with_subdomain.first
|
|
|
|
current_admin.reset_switch_site_token!
|
|
|
|
else
|
|
|
|
redirect_to admin_pages_path
|
|
|
|
end
|
2010-07-28 00:42:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
if account = Account.find_using_switch_site_token(params[:token])
|
|
|
|
account.reset_switch_site_token!
|
|
|
|
sign_in(account)
|
|
|
|
redirect_to admin_pages_path
|
|
|
|
else
|
2010-07-29 10:46:13 +00:00
|
|
|
redirect_to new_admin_session_path, :alert => t('flash.admin.cross_domain_sessions.create.alert')
|
2010-07-28 00:42:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|