app/controllers/catalog_controller.rb
# makes sure user is logged in, and inits a hip pilot object if so
makes sure user is logged in, and inits a hip pilot object if so
makes sure user is logged in and inits a hip pilot object if so
def require_login
    unless current_user
      if request.xhr?
        if action_name == 'email'
          message = 'Please log in to send a record by email.'
        elsif action_name == 'sms_form' or action_name == 'sms_send'
          message = 'To send a record by text, please log in and provide the cell number and carrier name.'
        else
          message = 'Please log in to continue' 
          logger.warn "Require login by something other than email and sms: #{action_name}"
        end
        flash[:notice] = message
        body = "<span data-force-login='#{new_user_session_url}' data-request-path='#{request.path}'>Request requires authentication, which can't be done over an xhr request.</span>"
        render html: body.html_safe
      else
        flash[:notice] = "Please log in." and raise Blacklight::Exceptions::AccessDenied
      end
    end
  end
def require_login unless current_user if request . xhr? if action_name == 'email' message = 'Please log in to send a record by email.' elsif action_name == 'sms_form' or action_name == 'sms_send' message = 'To send a record by text, please log in and provide the cell number and carrier name.' else message = 'Please log in to continue' logger . warn "Require login by something other than email and sms: #{action_name}" end flash [ :notice ] = message body = "<span data-force-login='#{new_user_session_url}' data-request-path='#{request.path}'>Request requires authentication, which can't be done over an xhr request.</span>" render html : body . html_safe else flash [ :notice ] = "Please log in." and raise Blacklight :: Exceptions :: AccessDenied end end end
makes sure user is logged in, and inits a hip pilot object if so
makes sure user is logged in and inits a hip pilot object if so
# ajaxy request, redirecting to login isn't going to work right, # give em a 403 telling em we can't do it. Body contains a data-force-login, # that our JS code will catch and redirect to authentication, and a data-request-url # that our JS code will use to... do overly complex hacky stuff so when they are done # logging in, they get the request modal again. # this shouldn't happen # raise the exception that will cause redirect to login screen.