Module: Cassette::Rubycas::Helper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cassette/rubycas/helper.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #cas_logout(to = root_url) ⇒ Object
- #current_user ⇒ Object
- #customer_only_filter ⇒ Object
- #employee_only_filter ⇒ Object
- #fake_user ⇒ Object
- #validate_authentication_ticket ⇒ Object
- #validate_raw_role!(role) ⇒ Object
- #validate_role!(role) ⇒ Object
Instance Method Details
#cas_logout(to = root_url) ⇒ Object
36 37 38 39 |
# File 'lib/cassette/rubycas/helper.rb', line 36 def cas_logout(to = root_url) session.destroy ::CASClient::Frameworks::Rails::Filter.logout(self, to) end |
#current_user ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cassette/rubycas/helper.rb', line 61 def current_user return fake_user if ENV["NOAUTH"] return nil unless session[:cas_user] @current_user ||= begin attributes = session[:cas_extra_attributes] Cassette::Authentication::User.new({ login: session[:cas_user], name: attributes.try(:[], :cn), email: attributes.try(:[], :email), authorities: attributes.try(:[], :authorities), type: attributes.try(:[], :type).try(:downcase) }) end end |
#customer_only_filter ⇒ Object
31 32 33 34 |
# File 'lib/cassette/rubycas/helper.rb', line 31 def customer_only_filter return if ENV["NOAUTH"] or current_user.blank? raise Cassette::Errors::NotACustomer unless current_user.customer? end |
#employee_only_filter ⇒ Object
26 27 28 29 |
# File 'lib/cassette/rubycas/helper.rb', line 26 def employee_only_filter return if ENV["NOAUTH"] or current_user.blank? raise Cassette::Errors::NotAnEmployee unless current_user.employee? end |
#fake_user ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/cassette/rubycas/helper.rb', line 41 def fake_user Cassette::Authentication::User.new({ login: "fake.user", name: "Fake User", email: "[email protected]", authorities: [], type: "customer" }) end |
#validate_authentication_ticket ⇒ Object
21 22 23 24 |
# File 'lib/cassette/rubycas/helper.rb', line 21 def validate_authentication_ticket return if ENV["NOAUTH"] ::CASClient::Frameworks::Rails::Filter.filter(self) end |