Created
October 28, 2016 15:21
-
-
Save jmflannery/5fc37eee4374315b9cbf05dab9ed5797 to your computer and use it in GitHub Desktop.
authenticate_with_http_token example in a rails controller
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
def authenticate_token | |
@user = authenticate_with_http_token do |key, options| | |
token = Token.find_by key: key | |
token.user if token | |
end | |
head 401 unless @user | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment