Last active
November 5, 2018 09:18
-
-
Save matija/e3fe8fa26b6ffab1a9372bcef7706db1 to your computer and use it in GitHub Desktop.
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_request! | |
fail StandardError.new('NotAuthenticatedError') unless user_id_included_in_auth_token? | |
@current_user = User.find(decoded_auth_token['user_id']) | |
rescue JWT::ExpiredSignature | |
raise StandardError.new('AuthenticationTimeoutError') | |
rescue JWT::VerificationError, JWT::DecodeError | |
raise StandardError.new('NotAuthenticatedError') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment