Sha256: ebaffd170d45f386e9c929bd44dd9baccd179dffd5d4207188ef6a9095104d9b
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module Cas class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_action :authenticate_user! before_action :set_current_user before_action :set_user_sites before_action :set_domain before_action :set_site private def set_current_user @current_user = current_user end def set_user_sites @user_sites = @current_user.sites if @current_user.present? end def set_domain @domain ||= (ENV["DOMAIN"] || request.domain) if @domain.blank? || (ENV["DOMAIN"].blank? && @domain == "localhost") @domain = ::Cas::Site.first!.domains.first end rescue ActiveRecord::RecordNotFound => e raise Cas::Exceptions::IncompleteSetup, "IncompleteSetup: check README.md. #{e.message}: #{e.inspect}" end def set_site if params[:site_id].present? @site = ::Cas::Site.find_by!(slug: params[:site_id]) else @site = ::Cas::Site .where("cas_sites.domains::text[] && '{#{@domain}}'::text[]") .first! end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cas-cms-1.0.0.alpha2 | app/controllers/cas/application_controller.rb |
cas-cms-1.0.0.alpha1 | app/controllers/cas/application_controller.rb |