Skip to content

Commit

Permalink
Return 403 on the method if registrations are not open
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Dec 22, 2018
1 parent 541479d commit 232e3dc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/controllers/api/v1/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ class Api::V1::AccountsController < Api::BaseController
before_action -> { doorkeeper_authorize! :follow, :'write:follows' }, only: [:follow, :unfollow]
before_action -> { doorkeeper_authorize! :follow, :'write:mutes' }, only: [:mute, :unmute]
before_action -> { doorkeeper_authorize! :follow, :'write:blocks' }, only: [:block, :unblock]
before_action -> { doorkeeper_authorize! }, only: [:create]
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: [:create]

before_action :require_user!, except: [:show, :create]
before_action :set_account, except: [:create]
before_action :check_account_suspension, only: [:show]
before_action :check_enabled_registrations, only: [:create]

respond_to :json

Expand Down Expand Up @@ -77,4 +78,8 @@ def check_account_suspension
def account_params
params.permit(:username, :email, :password)
end

def check_enabled_registrations
forbidden if single_user_mode? || !Setting.open_registrations
end
end

0 comments on commit 232e3dc

Please sign in to comment.