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

Support for both Api and webapp #41

Open
ausangshukla opened this issue Apr 16, 2024 · 1 comment
Open

Support for both Api and webapp #41

ausangshukla opened this issue Apr 16, 2024 · 1 comment

Comments

@ausangshukla
Copy link

  1. I have an existing web app with devise, and user login via a UI
  2. I want to enable APIs for the existing codebase
  3. Does this gem support both simultaneously?
  4. How can I set the current_user if the authentication is via devise-api gem ?

Thanks in advance

@ausangshukla
Copy link
Author

ausangshukla commented Apr 16, 2024

For those looking to do this, here is what Ive done to make it work

def authenticate_user!
    if request.headers['Authorization'].present?
      authenticate_devise_api_token!
      @current_user = current_devise_api_user
    else
      super
    end
  end

  def verify_authenticity_token
    super if request.headers['Authorization'].blank? 
  end

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

1 participant