check current user session
This commit is contained in:
@@ -2,6 +2,8 @@ class BaseCrmController < ActionController::Base
|
|||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "CRM"
|
layout "CRM"
|
||||||
|
|
||||||
|
before_action :check_user
|
||||||
|
|
||||||
#before_action :check_installation
|
#before_action :check_installation
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
@@ -22,8 +24,10 @@ class BaseCrmController < ActionController::Base
|
|||||||
{ locale: I18n.locale }
|
{ locale: I18n.locale }
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_user
|
def check_user
|
||||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
if current_user.nil?
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#Shop Name in Navbor
|
#Shop Name in Navbor
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ class BaseInventoryController < ActionController::Base
|
|||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "inventory"
|
layout "inventory"
|
||||||
|
|
||||||
|
before_action :check_user
|
||||||
|
|
||||||
#before_action :check_installation
|
#before_action :check_installation
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
@@ -12,8 +14,10 @@ class BaseInventoryController < ActionController::Base
|
|||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_user
|
def check_user
|
||||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
if current_user.nil?
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#Shop Name in Navbor
|
#Shop Name in Navbor
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ class BaseOqsController < ActionController::Base
|
|||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "OQS"
|
layout "OQS"
|
||||||
|
|
||||||
|
before_action :check_user
|
||||||
|
|
||||||
#before_action :check_installation
|
#before_action :check_installation
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
@@ -21,9 +23,11 @@ class BaseOqsController < ActionController::Base
|
|||||||
def default_url_options
|
def default_url_options
|
||||||
{ locale: I18n.locale }
|
{ locale: I18n.locale }
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_user
|
def check_user
|
||||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
if current_user.nil?
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#Shop Name in Navbor
|
#Shop Name in Navbor
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class BaseOrigamiController < ActionController::Base
|
|||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "origami"
|
layout "origami"
|
||||||
|
|
||||||
# before_action :checkin_process
|
before_action :check_user
|
||||||
|
|
||||||
#before_action :check_installation
|
#before_action :check_installation
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
@@ -14,8 +14,10 @@ class BaseOrigamiController < ActionController::Base
|
|||||||
redirect_to origami_dashboard_path
|
redirect_to origami_dashboard_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_user
|
def check_user
|
||||||
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
if current_user.nil?
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# def checkin_process
|
# def checkin_process
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ class BaseReportController < ActionController::Base
|
|||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "application"
|
layout "application"
|
||||||
|
|
||||||
|
before_action :check_user
|
||||||
|
|
||||||
#before_action :check_installation
|
#before_action :check_installation
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
@@ -83,6 +85,12 @@ class BaseReportController < ActionController::Base
|
|||||||
return from, to
|
return from, to
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_user
|
||||||
|
if current_user.nil?
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#Shop Name in Navbor
|
#Shop Name in Navbor
|
||||||
def shop_detail
|
def shop_detail
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
|
|||||||
@@ -2,13 +2,21 @@ class BaseWaiterController < ActionController::Base
|
|||||||
include LoginVerification
|
include LoginVerification
|
||||||
layout "waiter"
|
layout "waiter"
|
||||||
|
|
||||||
|
before_action :check_user
|
||||||
|
|
||||||
#before_action :check_installation
|
#before_action :check_installation
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
helper_method :shop_detail
|
helper_method :shop_detail
|
||||||
|
|
||||||
#Shop Name in Navbor
|
def check_user
|
||||||
def shop_detail
|
if current_user.nil?
|
||||||
@shop = Shop.first
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#Shop Name in Navbor
|
||||||
|
def shop_detail
|
||||||
|
@shop = Shop.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ module LoginVerification
|
|||||||
protected
|
protected
|
||||||
# Authenticate the user with token based authentication
|
# Authenticate the user with token based authentication
|
||||||
def authenticate
|
def authenticate
|
||||||
authenticate_session_token || render_unauthorized
|
authenticate_session_token || render_unauthorized
|
||||||
end
|
end
|
||||||
|
|
||||||
def authenticate_session_token
|
def authenticate_session_token
|
||||||
token = session[:session_token]
|
token = session[:session_token]
|
||||||
if (token)
|
if (token)
|
||||||
#@current_user = User.find_by(api_key: token)
|
#@current_user = User.find_by(api_key: token)
|
||||||
@@ -50,7 +50,7 @@ module LoginVerification
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_unauthorized()
|
def render_unauthorized
|
||||||
redirect_to root_path
|
redirect_to root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,21 @@ class HomeController < ApplicationController
|
|||||||
# layout "application", except: [:index, :show]
|
# layout "application", except: [:index, :show]
|
||||||
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
|
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
|
||||||
|
|
||||||
|
before_action :check_user, only: :dashboard
|
||||||
|
|
||||||
helper_method :shop_detail
|
helper_method :shop_detail
|
||||||
|
|
||||||
|
# Special check for only dashboard
|
||||||
|
def check_user
|
||||||
|
if current_user.nil?
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_user
|
||||||
|
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
||||||
@employees = Employee.all.order("name asc")
|
@employees = Employee.all.order("name asc")
|
||||||
|
|||||||
Reference in New Issue
Block a user