From 821b1444dcc147b9c1205326a2d28651c369a52d Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Fri, 11 Jul 2014 14:55:36 +0200 Subject: Moved check for allow_registration into filter. --- app/controllers/users_controller.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'app/controllers/users_controller.rb') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a623653..0f822cb 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -8,6 +8,7 @@ class UsersController < UsersBaseController before_filter :redirect_if_logged_in, :only => [:new] before_filter :require_admin, :only => [:index, :deactivate, :enable] before_filter :fetch_user, :only => [:show, :edit, :update, :destroy, :deactivate, :enable] + before_filter :require_registration_allowed, only: :new respond_to :html @@ -26,11 +27,7 @@ class UsersController < UsersBaseController end def new - if APP_CONFIG[:allow_registration] - @user = User.new - else - redirect_to home_path - end + @user = User.new end def show @@ -70,4 +67,12 @@ class UsersController < UsersBaseController end end + protected + + def require_registration_allowed + unless APP_CONFIG[:allow_registration] + redirect_to home_path + end + end + end -- cgit v1.2.3