Module: Warden::GitHub::Rails::ControllerHelpers
- Defined in:
- lib/warden/github/rails/controller_helpers.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#github_authenticate!(scope = Rails.default_scope) ⇒ Object
Initiates the OAuth flow if not already authenticated for the specified scope.
-
#github_authenticated?(scope = Rails.default_scope) ⇒ Boolean
Checks whether a user is logged in for the specified scope.
-
#github_logout(scope = Rails.default_scope) ⇒ Object
Logs out a user if currently logged in for the specified scope.
-
#github_session(scope = Rails.default_scope) ⇒ Object
Accessor for the currently signed in user’s session.
-
#github_user(scope = Rails.default_scope) ⇒ Object
Returns the currently signed in user for the specified scope.
Class Method Details
.included(klass) ⇒ Object
5 6 7 |
# File 'lib/warden/github/rails/controller_helpers.rb', line 5 def self.included(klass) klass.helper_method(:github_authenticated?, :github_user) end |
Instance Method Details
#github_authenticate!(scope = Rails.default_scope) ⇒ Object
Initiates the OAuth flow if not already authenticated for the specified scope.
11 12 13 |
# File 'lib/warden/github/rails/controller_helpers.rb', line 11 def github_authenticate!(scope=Rails.default_scope) request.env['warden'].authenticate!(:scope => scope) end |
#github_authenticated?(scope = Rails.default_scope) ⇒ Boolean
Checks whether a user is logged in for the specified scope.
21 22 23 |
# File 'lib/warden/github/rails/controller_helpers.rb', line 21 def github_authenticated?(scope=Rails.default_scope) request.env['warden'].authenticated?(scope) end |
#github_logout(scope = Rails.default_scope) ⇒ Object
Logs out a user if currently logged in for the specified scope.
16 17 18 |
# File 'lib/warden/github/rails/controller_helpers.rb', line 16 def github_logout(scope=Rails.default_scope) request.env['warden'].logout(scope) end |
#github_session(scope = Rails.default_scope) ⇒ Object
Accessor for the currently signed in user’s session. This will be cleared once logged out.
33 34 35 |
# File 'lib/warden/github/rails/controller_helpers.rb', line 33 def github_session(scope=Rails.default_scope) request.env['warden'].session(scope) if github_authenticated?(scope) end |
#github_user(scope = Rails.default_scope) ⇒ Object
Returns the currently signed in user for the specified scope. See the documentation for Warden::GitHub::User for available methods.
27 28 29 |
# File 'lib/warden/github/rails/controller_helpers.rb', line 27 def github_user(scope=Rails.default_scope) request.env['warden'].user(scope) end |