Module: Shibbolite::Helpers
- Extended by:
- ActiveSupport::Concern
- Included in:
- Filters, ShibbolethController
- Defined in:
- app/concerns/shibbolite/helpers.rb
Instance Method Summary collapse
-
#anonymous_user? ⇒ Boolean
true when user hasn’t signed in to SSO.
-
#current_user ⇒ Object
sets current user from the session user id.
-
#guest_user? ⇒ Boolean
true when the user signed in to the SSO but they haven’t been registered with the app.
-
#logged_in? ⇒ Boolean
true when the primary_user_id has been saved in session.
-
#registered_user? ⇒ Boolean
true when the user exists in the database.
- #user_has_id?(id, user = nil) ⇒ Boolean
-
#user_has_matching_attribute?(attr, value) ⇒ Boolean
this method matches against the raw environment variables instead of the database attributes.
- #user_in_group?(group, user = nil) ⇒ Boolean
Instance Method Details
#anonymous_user? ⇒ Boolean
true when user hasn’t signed in to SSO
21 22 23 |
# File 'app/concerns/shibbolite/helpers.rb', line 21 def anonymous_user? not logged_in? end |
#current_user ⇒ Object
sets current user from the session user id
16 17 18 |
# File 'app/concerns/shibbolite/helpers.rb', line 16 def current_user logged_in? ? @current_user ||= Shibbolite.user_class.find_user(session[Shibbolite.pid]) : nil end |
#guest_user? ⇒ Boolean
true when the user signed in to the SSO but they haven’t been registered with the app
27 28 29 |
# File 'app/concerns/shibbolite/helpers.rb', line 27 def guest_user? current_user.nil? and logged_in? end |
#logged_in? ⇒ Boolean
true when the primary_user_id has been saved in session
11 12 13 |
# File 'app/concerns/shibbolite/helpers.rb', line 11 def logged_in? session[Shibbolite.pid] end |
#registered_user? ⇒ Boolean
true when the user exists in the database
32 33 34 |
# File 'app/concerns/shibbolite/helpers.rb', line 32 def registered_user? current_user end |
#user_has_id?(id, user = nil) ⇒ Boolean
42 43 44 45 46 |
# File 'app/concerns/shibbolite/helpers.rb', line 42 def user_has_id?(id, user = nil) user ||= current_user return false unless user user.id == id end |
#user_has_matching_attribute?(attr, value) ⇒ Boolean
this method matches against the raw environment variables
instead of the database attributes
50 51 52 |
# File 'app/concerns/shibbolite/helpers.rb', line 50 def user_has_matching_attribute?(attr, value) request.env[attr.to_s] == value end |
#user_in_group?(group, user = nil) ⇒ Boolean
36 37 38 39 40 |
# File 'app/concerns/shibbolite/helpers.rb', line 36 def user_in_group?(group, user = nil) user ||= current_user return false unless user user.group == group.to_s end |