From 6709e9af7d813e4e51105b1dd03c0bb518cd8b8b Mon Sep 17 00:00:00 2001 From: ABCanG Date: Tue, 15 Aug 2017 12:07:09 +0900 Subject: [PATCH] Fix require_user! behavior when not logged in --- app/controllers/api/base_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 105a2859d3ec1..6ede63c79096e 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -62,10 +62,11 @@ def current_user end def require_user! - current_resource_owner - set_user_activity - rescue ActiveRecord::RecordNotFound - render json: { error: 'This method requires an authenticated user' }, status: 422 + if current_user + set_user_activity + else + render json: { error: 'This method requires an authenticated user' }, status: 422 + end end def render_empty