Cannot override json response of authenticate_user!
Hi, I am making a REST API server. I have overridden all devise_token_auth resposes. The only one I can't override is from authenticate_user!
Looking the code, I saw that this function come from devise_token_auth/lib/devise_token_auth/controllers/helpers.rb (Line 32) and the response is did direcly from that code.
Is there any way to override this?
Thanks
Hi, any progress on this? thanks
+1
+1
You can overwrite this method for selected resource in controller that includes DeviseTokenAuth::Concerns::SetUserByToken.
For example:
class ApplicationController < ActionController::API
include DeviseTokenAuth::Concerns::SetUserByToken
private
def authenticate_user!
unless current_user
return render json: {
errors: ["You shall not pass!"]
}, status: 401
end
end
end
nice! that do the work Many thanks :)