forked from saurabh/orbit4-5
47 lines
1.0 KiB
Ruby
47 lines
1.0 KiB
Ruby
class ApplicationController < ActionController::Base
|
|
# Prevent CSRF attacks by raising an exception.
|
|
# For APIs, you may want to use :null_session instead.
|
|
protect_from_forgery with: :exception
|
|
before_action :set_locale
|
|
helper_method :current_site, :current_user
|
|
|
|
def default_url_options(options={})
|
|
{ locale: I18n.locale }
|
|
end
|
|
|
|
def set_locale
|
|
I18n.locale = params[:locale] || I18n.default_locale
|
|
end
|
|
|
|
def get_layout
|
|
f = File.join("../../templates/", "#{@key}", '/home/page.html.erb')
|
|
end
|
|
|
|
def get_key
|
|
@key = Template::KEY
|
|
end
|
|
|
|
def current_site
|
|
@current_site = Site.find_by(site_active: true)
|
|
end
|
|
|
|
private
|
|
|
|
def current_user
|
|
@current_user ||= User.find(session[:user_id]) if session[:user_id]
|
|
end
|
|
|
|
protected
|
|
|
|
def authenticate_user
|
|
if session[:user_id]
|
|
# set current user object to @current_user object variable
|
|
@current_user = User.find(session[:user_id])
|
|
return true
|
|
else
|
|
redirect_to new_session_path
|
|
return false
|
|
end
|
|
end
|
|
end
|