From 25a212bb702c199b9dcb4bf6061df0d3852b74c6 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 23 Feb 2018 14:45:53 +0630 Subject: [PATCH] update base controllers --- app/controllers/base_crm_controller.rb | 1 + app/controllers/base_inventory_controller.rb | 1 + app/controllers/base_oqs_controller.rb | 1 + app/controllers/base_origami_controller.rb | 1 + app/controllers/base_report_controller.rb | 1 + app/controllers/base_waiter_controller.rb | 1 + app/controllers/concerns/license_verification.rb | 3 ++- app/controllers/concerns/login_verification.rb | 3 ++- app/controllers/home_controller.rb | 5 +++-- app/controllers/print_settings_controller.rb | 1 + 10 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index 5c412fcf..970ffe17 100755 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,4 +1,5 @@ class BaseCrmController < ApplicationController + include LoginVerification layout "CRM" #before_action :check_installation diff --git a/app/controllers/base_inventory_controller.rb b/app/controllers/base_inventory_controller.rb index f44747d3..1d99c766 100755 --- a/app/controllers/base_inventory_controller.rb +++ b/app/controllers/base_inventory_controller.rb @@ -1,4 +1,5 @@ class BaseInventoryController < ApplicationController + include LoginVerification layout "inventory" #before_action :check_installation diff --git a/app/controllers/base_oqs_controller.rb b/app/controllers/base_oqs_controller.rb index f1f2831a..b50684de 100755 --- a/app/controllers/base_oqs_controller.rb +++ b/app/controllers/base_oqs_controller.rb @@ -1,4 +1,5 @@ class BaseOqsController < ApplicationController + include LoginVerification layout "OQS" #before_action :check_installation diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index 58d9b801..8a79c009 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -1,4 +1,5 @@ class BaseOrigamiController < ApplicationController + include LoginVerification layout "origami" # before_action :checkin_process diff --git a/app/controllers/base_report_controller.rb b/app/controllers/base_report_controller.rb index f7551f22..a9fe207b 100755 --- a/app/controllers/base_report_controller.rb +++ b/app/controllers/base_report_controller.rb @@ -1,4 +1,5 @@ class BaseReportController < ApplicationController + include LoginVerification layout "application" #before_action :check_installation diff --git a/app/controllers/base_waiter_controller.rb b/app/controllers/base_waiter_controller.rb index 248e32a6..ca793e17 100755 --- a/app/controllers/base_waiter_controller.rb +++ b/app/controllers/base_waiter_controller.rb @@ -1,4 +1,5 @@ class BaseWaiterController < ApplicationController + include LoginVerification layout "waiter" #before_action :check_installation diff --git a/app/controllers/concerns/license_verification.rb b/app/controllers/concerns/license_verification.rb index bfa40f03..b838a48f 100644 --- a/app/controllers/concerns/license_verification.rb +++ b/app/controllers/concerns/license_verification.rb @@ -13,7 +13,7 @@ module LicenseVerification if (!@license.nil?) # logger.info "Location - " + @license.name ActiveRecord::Base.establish_connection(website_connection(@license)) - authenticate_session_token + # authenticate_session_token # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema else # reconnect_default_db @@ -40,6 +40,7 @@ module LicenseVerification @user = Employee.authenticate_by_token(token) if !@user flash[:notice] = 'Invalid Access!' + redirect_to root_path end end end diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 7ddf3cec..bb98cf2e 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -2,7 +2,7 @@ module LoginVerification extend ActiveSupport::Concern included do - before_action :authenticate + before_action :authenticate_session_token helper_method :current_company,:current_login_employee end @@ -25,6 +25,7 @@ module LoginVerification #Maybe log - login? else flash[:notice] = 'Invalid Access!' + # return false end end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index ea411fa0..5c0d4117 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,11 +1,12 @@ class HomeController < ApplicationController + include LoginVerification # layout "application", except: [:index, :show] # skip_before_action only: [:index, :show, :create, :update, :destroy] def index # @employees = Employee.all_emp_except_waiter.order("name asc") @employees = Employee.all.order("name asc") - @login_form = LoginForm.new() + @login_form = LoginForm.new() render "layouts/login_dashboard", layout: false end @@ -56,7 +57,7 @@ class HomeController < ApplicationController render :index end else - redirect_to origami_root_path, :notice => "Username and Password doesn't match!" + redirect_to root_path, :notice => "Username and Password doesn't match!" end end diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index a72319b3..329b0fa2 100755 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -1,4 +1,5 @@ class PrintSettingsController < ApplicationController + include LoginVerification load_and_authorize_resource except: [:create] before_action :set_print_setting, only: [:show, :edit, :update, :destroy]