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/v1/users_controller.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'app/controllers/v1/users_controller.rb') diff --git a/app/controllers/v1/users_controller.rb b/app/controllers/v1/users_controller.rb index 881708a..abaefd8 100644 --- a/app/controllers/v1/users_controller.rb +++ b/app/controllers/v1/users_controller.rb @@ -5,6 +5,7 @@ module V1 before_filter :fetch_user, :only => [:update] before_filter :require_admin, :only => [:index] before_filter :require_token, :only => [:update] + before_filter :require_registration_allowed, only: :create respond_to :json @@ -19,12 +20,8 @@ module V1 end def create - if APP_CONFIG[:allow_registration] - @user = Account.create(params[:user]) - respond_with @user # return ID instead? - else - head :forbidden - end + @user = Account.create(params[:user]) + respond_with @user # return ID instead? end def update @@ -32,5 +29,11 @@ module V1 respond_with @user end + def require_registration_allowed + unless APP_CONFIG[:allow_registration] + head :forbidden + end + end + end end -- cgit v1.2.3