checking for banned user, better banned msg style
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery
|
||||
before_filter :update_ip, :update_seen
|
||||
before_filter :update_ip, :update_seen, :check_banned
|
||||
# force_ssl
|
||||
|
||||
http_basic_authenticate_with name: "redstone", password: "sheep_"
|
||||
@@ -18,6 +18,8 @@ class ApplicationController < ActionController::Base
|
||||
helper_method :superadmin?
|
||||
helper_method :donor?
|
||||
helper_method :confirmed?
|
||||
|
||||
|
||||
private
|
||||
|
||||
def update_ip
|
||||
@@ -32,6 +34,15 @@ class ApplicationController < ActionController::Base
|
||||
@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?)
|
||||
|
||||
Reference in New Issue
Block a user