Permalink
Browse files

small refactoring on application_controller

  • Loading branch information...
1 parent 344af40 commit a5ca508b661c8c4cfa4ab349f685099b963bd8f3 @demental demental committed Dec 7, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 app/controllers/application_controller.rb
View
12 app/controllers/application_controller.rb
@@ -10,18 +10,22 @@ def current_user
def authorize
if current_user.nil?
- redirect_to login_url, :alert => 'Not authorized'
+ deny_access!
elsif params[:action] == 'tagged' && ( !current_user.admin? && !current_user.allowed_tags.include?(params[:tag]) )
- redirect_to login_url, :alert => 'Not authorized'
+ deny_access!
end
end
-
+
def authorize_admin
if current_user.nil? || !current_user.admin?
- redirect_to login_url, :alert => 'Not authorized'
+ deny_access!
end
end
+ def deny_access!
+ redirect_to login_url, :alert => 'Not authorized'
+ end
+
def allowed_groups
if current_user.admin?
Group.all

0 comments on commit a5ca508

Please sign in to comment.