Created
January 18, 2017 22:30
-
-
Save DidiRaggio/0f2fbf7434e8818b7eaa502e97cfdf49 to your computer and use it in GitHub Desktop.
custom authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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