update multi_tenancy and current shop
This commit is contained in:
@@ -16,28 +16,19 @@ module LoginVerification
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_shop
|
|
||||||
begin
|
|
||||||
return Shop.current_shop
|
|
||||||
rescue
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def current_login_employee
|
def current_login_employee
|
||||||
@employee = Employee.find_by_token_session(session[:session_token])
|
@employee ||= current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_user
|
def current_user
|
||||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get current Cashiers
|
# Get current Cashiers
|
||||||
def get_cashier
|
def get_cashier
|
||||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
@cashier ||= Employee.where("role = 'cashier' AND token_session <> ''")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
#Shop Name in Navbor
|
#Shop Name in Navbor
|
||||||
def shop_detail
|
def shop_detail
|
||||||
@shop ||= current_shop
|
@shop ||= current_shop
|
||||||
|
|||||||
@@ -4,16 +4,18 @@ module MultiTenancy
|
|||||||
included do
|
included do
|
||||||
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
|
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
|
||||||
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
|
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
|
||||||
|
helper_method :current_shop if respond_to? :helper_method
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_shop_by_subdomain_or_frist
|
def find_shop_by_subdomain_or_frist
|
||||||
if request.subdomain.present?
|
if request.subdomains.last
|
||||||
shop_code = request.subdomain.partition('-').last
|
set_current_tenant(Shop.find_by(shop_code: request.subdomains.last.partition('-').last))
|
||||||
@shop = Shop.find_by(shop_code: shop_code)
|
|
||||||
else
|
|
||||||
@shop = Shop.first
|
|
||||||
end
|
end
|
||||||
set_current_tenant(@shop)
|
current_shop
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_shop
|
||||||
|
@shop ||= Shop.current_shop
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ module TokenVerification
|
|||||||
before_action :authenticate
|
before_action :authenticate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
# Authenticate the user with token based authentication
|
# Authenticate the user with token based authentication
|
||||||
def authenticate
|
def authenticate
|
||||||
authenticate_token || render_unauthorized
|
authenticate_token || render_unauthorized
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_token
|
def authenticate_token
|
||||||
authenticate_with_http_token do |token, options|
|
authenticate_with_http_token do |token, options|
|
||||||
# Rails.logger.debug "token - " + token.to_s
|
# Rails.logger.debug "token - " + token.to_s
|
||||||
if(options.length !=0 && options["from"] == "DOEMAL")
|
if(options.length !=0 && options["from"] == "DOEMAL")
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ class Shop < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.current_shop
|
def self.current_shop
|
||||||
ActsAsTenant.current_tenant
|
RequestStore["current_shop"] ||= ActsAsTenant.current_tenant || Shop.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user