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