Module: Cul::Omniauth::AuthorizingController
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/controllers/concerns/cul/omniauth/authorizing_controller.rb
Instance Method Summary collapse
- #access_denied(url = nil) ⇒ Object
- #authorize_action ⇒ Object
- #redirect_back_or_default(default) ⇒ Object
- #require_no_user ⇒ Object
- #require_user ⇒ Object
- #store_location ⇒ Object
Instance Method Details
#access_denied(url = nil) ⇒ Object
48 49 50 51 52 |
# File 'app/controllers/concerns/cul/omniauth/authorizing_controller.rb', line 48 def access_denied(url=nil) flash[:notice] = I18n.t('cul.omniauth.denied') redirect_to url || root_url return false end |
#authorize_action ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/concerns/cul/omniauth/authorizing_controller.rb', line 34 def if can? :"#{controller_name.to_s}##{params[:action].to_s}", Cul::Omniauth::AbilityProxy.new return true else if current_user access_denied return false end end store_location redirect_to_login return false end |
#redirect_back_or_default(default) ⇒ Object
12 13 14 15 |
# File 'app/controllers/concerns/cul/omniauth/authorizing_controller.rb', line 12 def redirect_back_or_default(default) redirect_to(session[:return_to] || default) session[:return_to] = nil end |
#require_no_user ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/controllers/concerns/cul/omniauth/authorizing_controller.rb', line 25 def require_no_user if current_user store_location flash[:notice] = I18n.t('cul.omniauth.only_guest') redirect_to root_url return false end end |
#require_user ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/controllers/concerns/cul/omniauth/authorizing_controller.rb', line 17 def require_user unless current_user store_location redirect_to_login return false end end |
#store_location ⇒ Object
8 9 10 |
# File 'app/controllers/concerns/cul/omniauth/authorizing_controller.rb', line 8 def store_location session[:return_to] = "#{request.protocol}#{request.host_with_port}#{request.fullpath}" end |