This repository has been archived on 2024-08-27. You can view files and clone it, but cannot push or open issues or pull requests.
redstoner.com/app/controllers/application_controller.rb
MrYummy 1316d7ca03 Added Searching Features
* Added Thread Search Feature

* Added User Search Feature

* Re-organized searching, added @mention support to author search
2017-06-18 13:11:36 -04:00

79 lines
1.4 KiB
Ruby

class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :update_ip, :update_seen, :check_banned
# TODO: use SSL
helper :all
include UsersHelper
include ApplicationHelper
helper_method :current_user
helper_method :disabled?
helper_method :banned?
helper_method :normal?
helper_method :mod?
helper_method :admin?
helper_method :superadmin?
helper_method :donor?
helper_method :confirmed?
private
def update_ip
current_user && current_user.update_attribute(:last_ip, request.remote_ip)
end
def update_seen
current_user && current_user.update_attribute(:last_seen, Time.now)
end
def current_user
@current_user ||= User.find_by_id(session[:user_id])
end
def check_banned
if current_user && current_user.banned?
session.delete(:user_id)
flash[:alert] = "You are banned!"
redirect_to login_path
end
end
#roles
def disabled?
!!(current_user && current_user.disabled?)
end
def banned?
!!(current_user && current_user.banned?)
end
def normal?
!!(current_user && current_user.normal?)
end
def mod?
!!(current_user && current_user.mod?)
end
def admin?
!!(current_user && current_user.admin?)
end
def superadmin?
!!(current_user && current_user.superadmin?)
end
def donor?
!!(current_user && current_user.donor?)
end
def confirmed?
!!(current_user && current_user.confirmed?)
end
end