Skip to content

Instantly share code, notes, and snippets.

@DidiRaggio
Created January 18, 2017 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DidiRaggio/0f2fbf7434e8818b7eaa502e97cfdf49 to your computer and use it in GitHub Desktop.
Save DidiRaggio/0f2fbf7434e8818b7eaa502e97cfdf49 to your computer and use it in GitHub Desktop.
custom authentication
module Authenticable
# Devise methods overwrites
def current_user
@current_user ||= User.find_by(auth_token: request.headers['Authorization'])
end
def authenticate_with_token!
render json: { errors: "Not authenticated" },
status: :unauthorized unless user_signed_in?
end
def user_signed_in?
current_user.present?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment