checking for banned user, better banned msg style

This commit is contained in:
jomo
2014-04-21 02:15:17 +02:00
parent 6b5ed6ea7f
commit 4458f341d4
2 changed files with 13 additions and 12 deletions

View File

@@ -438,16 +438,7 @@ and (min-width: 0px) //TODO
float: right;
}
.user-banned {
background: #AB0000;
color: white;
font-weight: bold;
padding: 4px;
display: block;
border-radius: 3px;
}
.user-unconfirmed {
.user-unconfirmed, .user-banned {
background: #AB0000;
color: white;
font-weight: bold;
@@ -455,7 +446,6 @@ and (min-width: 0px) //TODO
display: inline-block;
border-radius: 3px;
margin: 10px 0;
box-shadow: 0 0 10px #000;
}
.btn {

View File

@@ -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?)