cleanup switch_to supplier and make facebook image https
This commit is contained in:
@@ -17,7 +17,6 @@ module Suppliers
|
||||
end
|
||||
|
||||
# GET
|
||||
#NOTE: temporary solution for development, if I am in production something is wrong
|
||||
def employee_and_supplier
|
||||
# database optimization, preloading
|
||||
FlatKeys.as_nested_structure(Supplier::PRELOAD_INCLUDES).last.each do |relation_name, includes|
|
||||
@@ -43,12 +42,14 @@ module Suppliers
|
||||
|
||||
def find_current_supplier!
|
||||
return current_supplier if current_supplier.present?
|
||||
if session[:supplier_id]
|
||||
supplier = Supplier.find(session[:supplier_id])
|
||||
supplier_id = request.headers['HTTP_SUPPLIER_ID'].presence || session[:supplier_id].presence
|
||||
if supplier_id and supplier_id != 'null' and supplier_id != 'undefined' # crying face icon! but javascript nulls and ruby presence are not brothers
|
||||
supplier = Supplier.find(supplier_id)
|
||||
if supplier.employee_ids.include?(current_employee.id)
|
||||
@current_supplier = supplier
|
||||
else
|
||||
session[:supplier_id] = nil
|
||||
raise CanCan::AccessDenied unless current_employee.active?
|
||||
end
|
||||
else
|
||||
@current_supplier = current_employee.suppliers.first
|
||||
|
||||
Reference in New Issue
Block a user