Module: Sinatra::Auth::Oauthed::Helpers
- Defined in:
- lib/sinatra/auth/oauthed.rb
Instance Method Summary collapse
- #_relative_url_for(path) ⇒ Object
- #authenticate!(*args) ⇒ Object
- #authenticated?(*args) ⇒ Boolean
- #logout! ⇒ Object
-
#oauthed_raw_request(path) ⇒ Object
Send a API GET request to the path defined in .env.
-
#oauthed_request(path) ⇒ Object
Send a API GET request to the path defined in .env and parse the response body.
-
#oauthed_user ⇒ Object
The authenticated user object.
- #warden ⇒ Object
Instance Method Details
#_relative_url_for(path) ⇒ Object
71 72 73 |
# File 'lib/sinatra/auth/oauthed.rb', line 71 def _relative_url_for(path) request.script_name + path end |
#authenticate!(*args) ⇒ Object
28 29 30 |
# File 'lib/sinatra/auth/oauthed.rb', line 28 def authenticate!(*args) warden.authenticate!(*args) end |
#authenticated?(*args) ⇒ Boolean
32 33 34 |
# File 'lib/sinatra/auth/oauthed.rb', line 32 def authenticated?(*args) warden.authenticated?(*args) end |
#logout! ⇒ Object
36 37 38 |
# File 'lib/sinatra/auth/oauthed.rb', line 36 def logout! warden.logout end |
#oauthed_raw_request(path) ⇒ Object
Send a API GET request to the path defined in .env
path - the path on api.github.com to hit
Returns a rest client response object
Examples
oauthed_raw_request("/user")
# => RestClient::Response
54 55 56 |
# File 'lib/sinatra/auth/oauthed.rb', line 54 def oauthed_raw_request(path) oauthed_user.oauthed_raw_request(path) end |
#oauthed_request(path) ⇒ Object
Send a API GET request to the path defined in .env and parse the response body
path - the path on api.github.com to hit
Returns a parsed JSON response
Examples
oauthed_request("/user")
# => { 'login' => 'atmos', ... }
67 68 69 |
# File 'lib/sinatra/auth/oauthed.rb', line 67 def oauthed_request(path) oauthed_user.oauthed_request(path) end |
#oauthed_user ⇒ Object
The authenticated user object
41 42 43 |
# File 'lib/sinatra/auth/oauthed.rb', line 41 def oauthed_user warden.user end |
#warden ⇒ Object
24 25 26 |
# File 'lib/sinatra/auth/oauthed.rb', line 24 def warden env['warden'] end |