82 lines
1.4 KiB
Ruby
82 lines
1.4 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
|
|
|
|
|
|
helper_method :has_permission?
|
|
|
|
|
|
|
|
|
|
def has_permission?(text)
|
|
true
|
|
end
|
|
|
|
|
|
def auth_fuser
|
|
if !current_fuser
|
|
redirect_to new_forum_auth_path
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def auth_admin
|
|
if !current_admin
|
|
redirect_to new_admin_admin_auth_path
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
private
|
|
|
|
def current_admin
|
|
|
|
if cookies[:admin_remember_token]
|
|
if @current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token])
|
|
@current_admin = Admin.find_by_remember_token(cookies[:admin_remember_token])
|
|
else
|
|
cookies[:admin_remember_token] =nil
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
def current_fuser
|
|
@current_fuser = nil
|
|
#@current_fuser ||= ForumUser.find_by_auth_token!(cookies[:forum_auth_token]) if cookies[:forum_auth_token]
|
|
|
|
|
|
#if session[:forum_user_id] and ForumUser.exists?(session[:forum_user_id])
|
|
# @current_fuser = ForumUser.find(session[:forum_user_id])
|
|
#else
|
|
# nil
|
|
#end
|
|
|
|
end
|
|
|
|
def moderator?
|
|
true if current_admin
|
|
end
|
|
|
|
|
|
helper_method :current_fuser, :moderator?, :current_admin
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|