Module: Rich::Cms::Auth
Defined Under Namespace
Classes: Specs
Instance Method Summary collapse
- #admin ⇒ Object
- #admin_label ⇒ Object
- #enabled? ⇒ Boolean
- #login ⇒ Object
- #login_required? ⇒ Boolean
- #logout ⇒ Object
- #setup {|specs| ... } ⇒ Object
Instance Method Details
#admin ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/rich/cms/auth.rb', line 55 def admin case specs.logic when :authlogic user_session = "#{klass.name}Session".constantize.find user_session.try klass_symbol when :devise current_controller.try :send, specs.current_admin_method if enabled? && specs.current_admin_method end if enabled? end |
#admin_label ⇒ Object
65 66 67 |
# File 'lib/rich/cms/auth.rb', line 65 def admin_label (admin.try(:send, specs.identifier) if enabled?) || "Rich-CMS" end |
#enabled? ⇒ Boolean
15 16 17 |
# File 'lib/rich/cms/auth.rb', line 15 def enabled? !!specs.logic end |
#login ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rich/cms/auth.rb', line 23 def login case specs.logic when :authlogic user_session = "#{klass.name}Session".constantize.new params[klass_symbol] user_session.save when :devise if Devise::VERSION.to_f < 1.1 warden.authenticate(:scope => klass_symbol) else begin sessions = Devise.mappings[klass_symbol].controllers[:sessions] Devise.mappings[klass_symbol].controllers[:sessions] = "rich/cms_sessions" warden.authenticate(:scope => klass_symbol) ensure Devise.mappings[klass_symbol].controllers[:sessions] = sessions end end end if enabled? !!admin end |
#login_required? ⇒ Boolean
19 20 21 |
# File 'lib/rich/cms/auth.rb', line 19 def login_required? enabled? && admin.nil? end |
#logout ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rich/cms/auth.rb', line 44 def logout case specs.logic when :authlogic user_session = "#{klass.name}Session".constantize.find user_session.try :destroy when :devise sign_out klass_symbol end if enabled? session[:rich_cms] = nil end |
#setup {|specs| ... } ⇒ Object
10 11 12 13 |
# File 'lib/rich/cms/auth.rb', line 10 def setup @specs = Specs.new yield specs end |