Commit 945855e

mo khan <mo@mokhan.ca>
2016-12-09 04:35:52
extract method not_authenticated
1 parent 2aa7a66
Changed files (1)
app
controllers
app/controllers/api/controller.rb
@@ -20,9 +20,13 @@ class Api::Controller < ActionController::Base
 
   def authenticate!
     return if current_user.present?
-    return render json: { errors: ['Not Authenticated'] }, status: :unauthorized
+    not_authenticated!
   rescue
-    return render json: { errors: ['Not Authenticated'] }, status: :unauthorized
+    not_authenticated!
+  end
+
+  def not_authenticated!
+    render json: { errors: ['Not Authenticated'] }, status: :unauthorized
   end
 
   def auth_token