Module: Sinatra::Warden::Helpers
- Defined in:
- lib/sinatra_warden/sinatra.rb
Instance Method Summary collapse
-
#authenticated?(*args) ⇒ Boolean
(also: #logged_in?)
Proxy to the authenticated? method on warden.
-
#authorize!(failure_path = nil) ⇒ Object
Require authorization for an action.
-
#user(*args) ⇒ Object
(also: #current_user)
Access the currently logged in user.
-
#user=(new_user) ⇒ Object
(also: #current_user=)
Set the currently logged in user Usage: self.user = @user.
-
#warden ⇒ Object
The main accessor for the warden proxy instance.
Instance Method Details
#authenticated?(*args) ⇒ Boolean Also known as: logged_in?
Proxy to the authenticated? method on warden
11 12 13 |
# File 'lib/sinatra_warden/sinatra.rb', line 11 def authenticated?(*args) warden.authenticated?(*args) end |
#authorize!(failure_path = nil) ⇒ Object
Require authorization for an action
33 34 35 |
# File 'lib/sinatra_warden/sinatra.rb', line 33 def (failure_path=nil) redirect(failure_path ? failure_path : .auth_failure_path) unless authenticated? end |
#user(*args) ⇒ Object Also known as: current_user
Access the currently logged in user
17 18 19 |
# File 'lib/sinatra_warden/sinatra.rb', line 17 def user(*args) warden.user(*args) end |
#user=(new_user) ⇒ Object Also known as: current_user=
Set the currently logged in user
Usage: self.user = @user
26 27 28 |
# File 'lib/sinatra_warden/sinatra.rb', line 26 def user=(new_user) warden.set_user(new_user) end |
#warden ⇒ Object
The main accessor for the warden proxy instance
6 7 8 |
# File 'lib/sinatra_warden/sinatra.rb', line 6 def warden request.env['warden'] end |