2011-10-30 23:02:41 +00:00
|
|
|
module Locomotive
|
2010-07-28 00:42:33 +00:00
|
|
|
class CrossDomainSessionsController < BaseController
|
|
|
|
|
2011-11-04 15:55:51 +00:00
|
|
|
layout '/locomotive/layouts/not_logged_in'
|
2010-07-28 00:42:33 +00:00
|
|
|
|
|
|
|
skip_before_filter :verify_authenticity_token
|
|
|
|
|
|
|
|
skip_before_filter :validate_site_membership
|
|
|
|
|
2011-10-30 23:02:41 +00:00
|
|
|
before_filter :require_account, :only => :new
|
2010-07-28 00:42:33 +00:00
|
|
|
|
2011-06-26 23:02:48 +00:00
|
|
|
skip_load_and_authorize_resource
|
|
|
|
|
2010-07-28 00:42:33 +00:00
|
|
|
def new
|
2011-11-04 15:55:51 +00:00
|
|
|
if site = current_locomotive_account.sites.detect { |s| s._id.to_s == params[:target_id] }
|
2010-10-29 14:19:41 +00:00
|
|
|
if Rails.env == 'development'
|
|
|
|
@target = site.full_subdomain
|
|
|
|
else
|
|
|
|
@target = site.domains_without_subdomain.first || site.full_subdomain
|
|
|
|
end
|
|
|
|
|
2011-11-04 15:55:51 +00:00
|
|
|
current_locomotive_account.reset_switch_site_token!
|
2010-07-28 10:17:56 +00:00
|
|
|
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
|
2011-10-30 23:02:41 +00:00
|
|
|
redirect_to new_admin_session_path, :alert => t('fash.locomotive.cross_domain_sessions.create.alert')
|
2010-07-28 00:42:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|