Skip to content

Instantly share code, notes, and snippets.

@karmiclychee
Created June 16, 2013 20:25
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 karmiclychee/5793284 to your computer and use it in GitHub Desktop.
Save karmiclychee/5793284 to your computer and use it in GitHub Desktop.
def authenticate_user
if authenticate_with_access_token { |t, o| User.all.exists?(access_token: t) }
current_user = User.find_by_access_token(t)
elsif authenticate_with_http_basic { |email, p| Users.all.authenticate(e, p) }
current_user = User.find_by_email(e)
else
head :unauthorized
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment