mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-11 18:26:50 +00:00
Enhance readability
This commit is contained in:
@@ -13,20 +13,7 @@ module DfcProvider
|
||||
# It means that our permissions to access data on another platform changed.
|
||||
# We will need to pull the updated data.
|
||||
def create
|
||||
unless current_user.is_a? ApiUser
|
||||
render_message(
|
||||
:unauthorized,
|
||||
"You need to authenticate as authorised platform (client_id).",
|
||||
)
|
||||
return
|
||||
end
|
||||
unless current_user.id == "lf-dev"
|
||||
render_message(
|
||||
:unauthorized,
|
||||
"Your client_id is not authorised on this platform.",
|
||||
)
|
||||
return
|
||||
end
|
||||
return if rendered_errors?
|
||||
|
||||
event = JSON.parse(request.body.read)
|
||||
enterprises_url = event["enterpriseUrlid"]
|
||||
@@ -51,6 +38,25 @@ module DfcProvider
|
||||
|
||||
private
|
||||
|
||||
def rendered_errors?
|
||||
unless current_user.is_a? ApiUser
|
||||
render_message(
|
||||
:unauthorized,
|
||||
"You need to authenticate as authorised platform (client_id).",
|
||||
)
|
||||
return true
|
||||
end
|
||||
unless current_user.id == "lf-dev"
|
||||
render_message(
|
||||
:unauthorized,
|
||||
"Your client_id is not authorised on this platform.",
|
||||
)
|
||||
return true
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
|
||||
def render_message(status, message)
|
||||
render status:, json: { success: false, message: }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user