lib/rodauth/features/json.rb in rodauth-2.30.0 vs lib/rodauth/features/json.rb in rodauth-2.31.0
- old
+ new
@@ -20,10 +20,11 @@
:use_json?,
)
auth_methods(
:json_request?,
+ :json_response_error?
)
auth_private_methods :json_response_body
def set_field_error(field, message)
@@ -63,10 +64,14 @@
def view(page, title)
return super unless use_json?
return_json_response
end
+ def json_response_error?
+ !!json_response[json_response_error_key]
+ end
+
private
def before_two_factor_manage_route
super if defined?(super)
if use_json?
@@ -170,10 +175,10 @@
def return_json_response
_return_json_response
end
def _return_json_response
- response.status ||= json_response_error_status if json_response[json_response_error_key]
+ response.status ||= json_response_error_status if json_response_error?
response['Content-Type'] ||= json_response_content_type
return_response _json_response_body(json_response)
end
def include_success_messages?