user role scoped layout and controller
This commit is contained in:
9
app/controllers/base_crm_controller.rb
Normal file
9
app/controllers/base_crm_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class BaseCrmController < ActionController::Base
|
||||
include LoginVerification
|
||||
layout "CRM"
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
|
||||
end
|
||||
@@ -3,6 +3,8 @@ module LoginVerification
|
||||
|
||||
included do
|
||||
before_action :authenticate
|
||||
helper_method :current_company,:current_login_employee
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -30,4 +32,28 @@ module LoginVerification
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
#all token authentication must be done here
|
||||
#response format must be set to JSON
|
||||
def current_company
|
||||
begin
|
||||
return Company.first
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def current_login_employee
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
|
||||
private
|
||||
def check_installation
|
||||
if current_company.nil?
|
||||
redirect_to install_path
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -33,7 +33,6 @@ class HomeController < ApplicationController
|
||||
def destroy
|
||||
session[:session_token] = nil
|
||||
redirect_to root_path
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user