license and local move to base action and update other base
This commit is contained in:
@@ -7,7 +7,8 @@ class ApplicationController < ActionController::Base
|
||||
# lookup domain for db from provision
|
||||
# before_action :set_locale
|
||||
|
||||
helper_method :current_company,:current_login_employee,:current_user
|
||||
# helper_method :current_company,:current_login_employee,:current_user
|
||||
|
||||
# alias_method :current_user, :current_login_employee,:current_user
|
||||
#this is base api base controller to need to inherit.
|
||||
#all token authentication must be done here
|
||||
@@ -18,6 +19,7 @@ class ApplicationController < ActionController::Base
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
private
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
@@ -36,7 +38,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
def current_login_employee
|
||||
if (!session[:session_token].nil?)
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
|
||||
@@ -9,19 +9,4 @@ class BaseCrmController < ActionController::Base
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
#change locallization
|
||||
def set_locale
|
||||
I18n.locale = params[:locale] || I18n.default_locale
|
||||
end
|
||||
|
||||
# RESTful url for localize
|
||||
def default_url_options
|
||||
{ locale: I18n.locale }
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -9,9 +9,4 @@ class BaseInventoryController < ActionController::Base
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -9,19 +9,4 @@ class BaseOqsController < ActionController::Base
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
#change locallization
|
||||
def set_locale
|
||||
I18n.locale = params[:locale] || I18n.default_locale
|
||||
end
|
||||
|
||||
# RESTful url for localize
|
||||
def default_url_options
|
||||
{ locale: I18n.locale }
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -6,16 +6,9 @@ class BaseOrigamiController < ActionController::Base
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to origami_root_path
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
# def checkin_process
|
||||
# CheckinJob.set(wait: 1.minute).perform_later()
|
||||
# end
|
||||
end
|
||||
|
||||
@@ -5,15 +5,13 @@ class BaseReportController < ActionController::Base
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :current_company,:current_login_employee,:current_user
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
PERIOD = {
|
||||
"today" => 0,
|
||||
"yesterday" => 1,
|
||||
@@ -83,8 +81,30 @@ class BaseReportController < ActionController::Base
|
||||
end
|
||||
|
||||
return from, to
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
# Get current Cashier
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
def current_company
|
||||
begin
|
||||
return Company.first
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
if (!session[:session_token].nil?)
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,4 +4,31 @@ class BaseWaiterController < ActionController::Base
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :current_company,:current_login_employee,:current_user
|
||||
|
||||
private
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
# Get current Cashier
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
def current_company
|
||||
begin
|
||||
return Company.first
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
if (!session[:session_token].nil?)
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,8 +2,8 @@ module LoginVerification
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :authenticate
|
||||
helper_method :current_company,:current_login_employee
|
||||
before_action :authenticate_session_token
|
||||
helper_method :current_company, :current_login_employee, :current_user, :get_cashier
|
||||
end
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
@@ -15,16 +15,24 @@ module LoginVerification
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||
end
|
||||
|
||||
# Get current Cashiers
|
||||
def get_cashier
|
||||
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
end
|
||||
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
def authenticate
|
||||
authenticate_session_token || render_unauthorized
|
||||
end
|
||||
|
||||
@@ -38,9 +46,9 @@ module LoginVerification
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
else
|
||||
flash[:notice] = 'Invalid Access!'
|
||||
# return false
|
||||
# else
|
||||
# flash[:notice] = 'Invalid Access!'
|
||||
# # return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user