Module: Cassette::Rubycas::Helper
- Extended by:
- ActiveSupport::Concern
- Includes:
- UserFactory
- 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
Methods included from UserFactory
Instance Method Details
#cas_logout(to = root_url) ⇒ Object
46 47 48 49 |
# File 'lib/cassette/rubycas/helper.rb', line 46 def cas_logout(to = root_url) session.destroy ::CASClient::Frameworks::Rails::Filter.logout(self, to) end |
#current_user ⇒ Object
69 70 71 72 73 74 |
# File 'lib/cassette/rubycas/helper.rb', line 69 def current_user return fake_user if ENV['NOAUTH'] return nil unless session[:cas_user] @current_user ||= from_session(session) end |
#customer_only_filter ⇒ Object
41 42 43 44 |
# File 'lib/cassette/rubycas/helper.rb', line 41 def customer_only_filter return if ENV['NOAUTH'] || current_user.blank? fail Cassette::Errors::NotACustomer unless current_user.customer? end |
#employee_only_filter ⇒ Object
36 37 38 39 |
# File 'lib/cassette/rubycas/helper.rb', line 36 def employee_only_filter return if ENV['NOAUTH'] || current_user.blank? fail Cassette::Errors::NotAnEmployee unless current_user.employee? end |
#fake_user ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/cassette/rubycas/helper.rb', line 51 def fake_user Cassette::Authentication::User.new(login: 'fake.user', name: 'Fake User', email: '[email protected]', authorities: [], type: 'customer') end |
#validate_authentication_ticket ⇒ Object
31 32 33 34 |
# File 'lib/cassette/rubycas/helper.rb', line 31 def validate_authentication_ticket return if ENV['NOAUTH'] ::CASClient::Frameworks::Rails::Filter.filter(self) end |
#validate_raw_role!(role) ⇒ Object
64 65 66 67 |
# File 'lib/cassette/rubycas/helper.rb', line 64 def validate_raw_role!(role) return if ENV['NOAUTH'] fail Cassette::Errors::Forbidden unless current_user.has_raw_role?(role) end |
#validate_role!(role) ⇒ Object
59 60 61 62 |
# File 'lib/cassette/rubycas/helper.rb', line 59 def validate_role!(role) return if ENV['NOAUTH'] fail Cassette::Errors::Forbidden unless current_user.has_role?(role) end |