Skip to content

Instantly share code, notes, and snippets.

@matija
Last active November 5, 2018 09:18
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 matija/e3fe8fa26b6ffab1a9372bcef7706db1 to your computer and use it in GitHub Desktop.
Save matija/e3fe8fa26b6ffab1a9372bcef7706db1 to your computer and use it in GitHub Desktop.
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