supplier client sections working with problematic authentication still active
This commit is contained in:
@@ -15,17 +15,24 @@ module Suppliers
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
respond_to do |format|
|
||||
format.html { redirect_to root_path, alert: 'Action forbidden'}
|
||||
format.json { render json: {errors: "403 Forbidden"}, status: :forbidden }
|
||||
format.json { render json: {errors: "403 Forbidden", ok: false}, status: :forbidden }
|
||||
end
|
||||
end
|
||||
|
||||
# GET
|
||||
#NOTE: temporary solution for development, if I am in production something is wrong
|
||||
def employee_and_supplier
|
||||
employee = current_employee || Employee.find_by_email('bterkuile@gmail.com')
|
||||
raise CanCan::AccessDenied unless employee.present?
|
||||
supplier = current_supplier || employee.suppliers.first
|
||||
employee.enrich_with_settings supplier.settings_for(employee)
|
||||
FlatKeys.as_nested_structure(Supplier::PRELOAD_INCLUDES).last.each do |relation_name, includes|
|
||||
relation_result = supplier.public_send(relation_name)
|
||||
relation_result.include_relations(includes) if relation_result.is_a?(Array)
|
||||
end
|
||||
render json: {
|
||||
employee: JSONAPI::Serializer.serialize(employee, serializer: Suppliers::EmployeeSerializer),
|
||||
supplier: JSONAPI::Serializer.serialize(supplier, serializer: Suppliers::SupplierSerializer),
|
||||
supplier: JSONAPI::Serializer.serialize(supplier, serializer: Suppliers::SupplierSerializer, include: Supplier::PRELOAD_INCLUDES),
|
||||
auth_token: employee.authentication_token,
|
||||
}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user