Skip to content

Commit 0dd84bc

Browse files
Tim WrightTim Wright
authored andcommitted
rework fix
1 parent c83fe80 commit 0dd84bc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

app/controllers/supplejack_api/supplejack_application_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ def authenticate_user!
2626
error_message = nil
2727

2828
if current_user
29+
# limit for anonymous users is reduced to 100 pages
30+
if RecordSchema.roles[current_user.role.to_sym].try(:anonymous)
31+
SupplejackApi::SearchParams.max_values.page = 100
32+
SupplejackApi::MltParams.max_values.page = 100
33+
end
34+
2935
if current_user.over_limit?
3036
error_message = if RecordSchema.roles[current_user.role.to_sym].try(:anonymous)
3137
I18n.t('users.anonymous_reached_limit')

app/params/supplejack_api/concerns/helpers_params.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def cast_param(_name, value)
2424
def integer_param(param, value)
2525
@user = User.find_by_auth_token(params[:api_key])
2626

27-
if param == 'page' && (@user.nil? || @user&.role == 'anonymous') && 100 < value
27+
if param == 'page' && self.class.max_values[param] == 100 && self.class.max_values[param] < value
2828
# rubocop:disable Layout/LineLength
2929
errors << "The #{param} parameter for anonymous users (without an API key) can not exceed #{self.class.max_values[param]}"
3030
# rubocop:enable Layout/LineLength

0 commit comments

Comments
 (0)