work off today

This commit is contained in:
2020-02-25 11:09:27 -05:00
parent da2ba6230d
commit 8740300b9a
34 changed files with 657 additions and 662 deletions
@@ -1,7 +1,10 @@
module Suppliers
class ApplicationController < ::ApplicationController
before_action :setup_employee_and_supplier!
load_and_authorize_resource
#load_and_authorize_resource
if Rails.env.development?
skip_before_action :setup_employee_and_supplier!, only: :employee_and_supplier
end
attr_reader :current_supplier
helper_method :current_supplier
layout 'supplier/app'
@@ -16,6 +19,16 @@ module Suppliers
end
end
# GET
def employee_and_supplier
employee = current_employee || Employee.find_by_email('bterkuile@gmail.com')
supplier = current_supplier || employee.suppliers.first
render json: {
employee: JSONAPI::Serializer.serialize(employee, serializer: Suppliers::EmployeeSerializer),
supplier: JSONAPI::Serializer.serialize(supplier, serializer: Suppliers::SupplierSerializer)
}
end
def setup_employee_and_supplier!
authenticate_employee!
find_current_supplier!
@@ -1,4 +1,5 @@
class Suppliers::SessionsController < Devise::SessionsController
respond_to :json
def destroy
session[:supplier_id] = nil