Module: Concerns::Auth

Extended by:
ActiveSupport::Concern
Included in:
ApplicationController
Defined in:
app/controllers/concerns/auth.rb

Overview

Controller concern for authentication methods

Split off from main ApplicationController to allow e.g. Doorkeeper to use it too.

Instance Method Summary collapse

Instance Method Details

#current_userObject (protected)



10
11
12
13
14
15
16
# File 'app/controllers/concerns/auth.rb', line 10

def current_user
  # check if there is a valid session and return the logged-in user (its object)
  return unless session[:user_id] && params[:foodcoop]

  # for shared-host installations. check if the cookie-subdomain fits to request.
  @current_user ||= User.undeleted.find_by_id(session[:user_id]) if session[:scope] == FoodsoftConfig.scope
end

#deny_accessObject (protected)



18
19
20
21
22
23
24
25
# File 'app/controllers/concerns/auth.rb', line 18

def deny_access
  session[:return_to] = request.original_url
  redirect_to root_url,
              alert: I18n.t('application.controller.error_denied',
                            sign_in: ActionController::Base.helpers.link_to(
                              t('application.controller.error_denied_sign_in'), 
                            ))
end