devise-api
devise-api copied to clipboard
Support for both Api and webapp
- I have an existing web app with devise, and user login via a UI
- I want to enable APIs for the existing codebase
- Does this gem support both simultaneously?
- How can I set the current_user if the authentication is via devise-api gem ?
Thanks in advance
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
Does this gem support both simultaneously?
yes you can use this gem with your existing web app. Just you need to create some helpers like already sent. 🙌