Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override json response of authenticate_user! #575

Closed
manuel-burato opened this issue Mar 15, 2016 · 5 comments
Closed

Cannot override json response of authenticate_user! #575

manuel-burato opened this issue Mar 15, 2016 · 5 comments

Comments

@manuel-burato
Copy link

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

@Alxzu
Copy link

Alxzu commented Apr 6, 2016

Hi, any progress on this? thanks

@NetanelBasal
Copy link

+1

1 similar comment
@the-bass
Copy link

+1

@daralbrecht
Copy link

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

@manuel-burato
Copy link
Author

nice! that do the work
Many thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants