Skip to content

Commit 232e3dc

Browse files
committed
Return 403 on the method if registrations are not open
1 parent 541479d commit 232e3dc

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

app/controllers/api/v1/accounts_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ class Api::V1::AccountsController < Api::BaseController
55
before_action -> { doorkeeper_authorize! :follow, :'write:follows' }, only: [:follow, :unfollow]
66
before_action -> { doorkeeper_authorize! :follow, :'write:mutes' }, only: [:mute, :unmute]
77
before_action -> { doorkeeper_authorize! :follow, :'write:blocks' }, only: [:block, :unblock]
8-
before_action -> { doorkeeper_authorize! }, only: [:create]
8+
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: [:create]
99

1010
before_action :require_user!, except: [:show, :create]
1111
before_action :set_account, except: [:create]
1212
before_action :check_account_suspension, only: [:show]
13+
before_action :check_enabled_registrations, only: [:create]
1314

1415
respond_to :json
1516

@@ -77,4 +78,8 @@ def check_account_suspension
7778
def account_params
7879
params.permit(:username, :email, :password)
7980
end
81+
82+
def check_enabled_registrations
83+
forbidden if single_user_mode? || !Setting.open_registrations
84+
end
8085
end

0 commit comments

Comments
 (0)