diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index e809d9d7a..b560b78c1 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -202,7 +202,13 @@ class App.Controller extends Spine.Controller callback: data.callback ) - authenticate: (checkOnly = false) -> + authenticate: (checkOnly = false, role) -> + + # role check + if role && !@isRole(role) + return false if checkOnly + @navigate '#login' + return false # return true if session exists return true if @Session.get() diff --git a/app/assets/javascripts/app/controllers/_channel/facebook.coffee b/app/assets/javascripts/app/controllers/_channel/facebook.coffee index a2c05fe63..1afef93ed 100644 --- a/app/assets/javascripts/app/controllers/_channel/facebook.coffee +++ b/app/assets/javascripts/app/controllers/_channel/facebook.coffee @@ -7,7 +7,7 @@ class Index extends App.ControllerContent constructor: -> super - return if !@authenticate() + return if !@authenticate(false, 'Admin') #@interval(@load, 60000) @load() diff --git a/app/assets/javascripts/app/controllers/_channel/twitter.coffee b/app/assets/javascripts/app/controllers/_channel/twitter.coffee index b239a02fd..c3be3fcff 100644 --- a/app/assets/javascripts/app/controllers/_channel/twitter.coffee +++ b/app/assets/javascripts/app/controllers/_channel/twitter.coffee @@ -7,7 +7,7 @@ class Index extends App.ControllerContent constructor: -> super - return if !@authenticate() + return if !@authenticate(false, 'Admin') #@interval(@load, 60000) @load() diff --git a/app/assets/javascripts/app/controllers/_profile/notification.coffee b/app/assets/javascripts/app/controllers/_profile/notification.coffee index 4cfbdc320..e117dd6f3 100644 --- a/app/assets/javascripts/app/controllers/_profile/notification.coffee +++ b/app/assets/javascripts/app/controllers/_profile/notification.coffee @@ -45,7 +45,7 @@ class Index extends App.Controller constructor: -> super - return if !@authenticate() + return if !@authenticate(false, 'Agent') @title 'Notifications', true @render() diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee index b85214ede..56ba5e30b 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee @@ -11,7 +11,7 @@ class App.TicketCreate extends App.Controller super # check authentication - if !@authenticate() + if !@authenticate(false, 'Agent') App.TaskManager.remove(@task_key) return diff --git a/app/assets/javascripts/app/controllers/calendar.coffee b/app/assets/javascripts/app/controllers/calendar.coffee index fdb2a21d0..ba1e94fec 100644 --- a/app/assets/javascripts/app/controllers/calendar.coffee +++ b/app/assets/javascripts/app/controllers/calendar.coffee @@ -10,7 +10,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') @interval(@load, 60000) #@load() diff --git a/app/assets/javascripts/app/controllers/chat.coffee b/app/assets/javascripts/app/controllers/chat.coffee index e34082d5a..9a0d913ac 100644 --- a/app/assets/javascripts/app/controllers/chat.coffee +++ b/app/assets/javascripts/app/controllers/chat.coffee @@ -316,7 +316,7 @@ class CustomerChatRouter extends App.ControllerPermanent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Chat') App.TaskManager.execute( key: 'CustomerChat' diff --git a/app/assets/javascripts/app/controllers/customer_ticket_create.coffee b/app/assets/javascripts/app/controllers/customer_ticket_create.coffee index 6243707cc..232199803 100644 --- a/app/assets/javascripts/app/controllers/customer_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/customer_ticket_create.coffee @@ -8,7 +8,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Customer') # set title @title 'New Ticket' diff --git a/app/assets/javascripts/app/controllers/getting_started.coffee b/app/assets/javascripts/app/controllers/getting_started.coffee index 42ee9acb3..97ba544a9 100644 --- a/app/assets/javascripts/app/controllers/getting_started.coffee +++ b/app/assets/javascripts/app/controllers/getting_started.coffee @@ -4,7 +4,7 @@ class Index extends App.ControllerContent constructor: -> super - if @authenticate(true) + if @authenticate(true, 'Admin') @navigate '#' return @@ -68,7 +68,7 @@ class AutoWizard extends App.ControllerContent super # if already logged in, got to # - if @authenticate(true) + if @authenticate(true, 'Admin') @navigate '#' return @@ -138,7 +138,7 @@ class Admin extends App.ControllerContent constructor: -> super - if @authenticate(true) + if @authenticate(true, 'Admin') @navigate '#' return @@ -260,7 +260,7 @@ class Base extends App.Wizard super # redirect if we are not admin - if !@authenticate(true) + if !@authenticate(true, 'Admin') @navigate '#' return @@ -394,7 +394,7 @@ class EmailNotification extends App.Wizard super # redirect if we are not admin - if !@authenticate(true) + if !@authenticate(true, 'Admin') @navigate '#' return @@ -512,7 +512,7 @@ class Channel extends App.ControllerContent super # redirect if we are not admin - if !@authenticate(true) + if !@authenticate(true, 'Admin') @navigate '#' return @@ -565,7 +565,7 @@ class ChannelEmailPreConfigured extends App.ControllerContent super # redirect if we are not admin - if !@authenticate(true) + if !@authenticate(true, 'Admin') @navigate '#' return @@ -616,7 +616,7 @@ class ChannelEmail extends App.Wizard super # redirect if we are not admin - if !@authenticate(true) + if !@authenticate(true, 'Admin') @navigate '#' return diff --git a/app/assets/javascripts/app/controllers/groups.coffee b/app/assets/javascripts/app/controllers/groups.coffee index c3fd370ec..897d2c503 100644 --- a/app/assets/javascripts/app/controllers/groups.coffee +++ b/app/assets/javascripts/app/controllers/groups.coffee @@ -3,7 +3,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') new App.ControllerGenericIndex( el: @el diff --git a/app/assets/javascripts/app/controllers/macro.coffee b/app/assets/javascripts/app/controllers/macro.coffee index d6d2c0e18..6f17216d8 100644 --- a/app/assets/javascripts/app/controllers/macro.coffee +++ b/app/assets/javascripts/app/controllers/macro.coffee @@ -3,7 +3,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') new App.ControllerGenericIndex( el: @el diff --git a/app/assets/javascripts/app/controllers/maintenance.coffee b/app/assets/javascripts/app/controllers/maintenance.coffee index 1f5046860..3cee0689a 100644 --- a/app/assets/javascripts/app/controllers/maintenance.coffee +++ b/app/assets/javascripts/app/controllers/maintenance.coffee @@ -6,7 +6,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'Maintenance', true diff --git a/app/assets/javascripts/app/controllers/object_manager.coffee b/app/assets/javascripts/app/controllers/object_manager.coffee index 8cad32ae6..11bd5fec8 100644 --- a/app/assets/javascripts/app/controllers/object_manager.coffee +++ b/app/assets/javascripts/app/controllers/object_manager.coffee @@ -5,7 +5,7 @@ class Index extends App.ControllerTabs super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'Objects', true diff --git a/app/assets/javascripts/app/controllers/overview.coffee b/app/assets/javascripts/app/controllers/overview.coffee index b182f664d..62f68ec5c 100644 --- a/app/assets/javascripts/app/controllers/overview.coffee +++ b/app/assets/javascripts/app/controllers/overview.coffee @@ -3,7 +3,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') new App.ControllerGenericIndex( el: @el diff --git a/app/assets/javascripts/app/controllers/package.coffee b/app/assets/javascripts/app/controllers/package.coffee index 6178d2163..e2c53ae30 100644 --- a/app/assets/javascripts/app/controllers/package.coffee +++ b/app/assets/javascripts/app/controllers/package.coffee @@ -6,7 +6,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'Packages', true diff --git a/app/assets/javascripts/app/controllers/session.coffee b/app/assets/javascripts/app/controllers/session.coffee index c69e5be51..57161d118 100644 --- a/app/assets/javascripts/app/controllers/session.coffee +++ b/app/assets/javascripts/app/controllers/session.coffee @@ -6,7 +6,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'Sessions', true diff --git a/app/assets/javascripts/app/controllers/settings.coffee b/app/assets/javascripts/app/controllers/settings.coffee index 19178754d..5ab53271f 100644 --- a/app/assets/javascripts/app/controllers/settings.coffee +++ b/app/assets/javascripts/app/controllers/settings.coffee @@ -2,7 +2,7 @@ class Branding extends App.ControllerTabs header: 'Branding' constructor: -> super - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'Branding', true @tabs = [ { name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'System::Branding' } } @@ -13,7 +13,7 @@ class System extends App.ControllerTabs header: 'System' constructor: -> super - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'System', true @tabs = [] if !App.Config.get('system_online_service') @@ -28,7 +28,7 @@ class Security extends App.ControllerTabs header: 'Security' constructor: -> super - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'Security', true @tabs = [ { name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Security::Base' } } @@ -42,7 +42,7 @@ class Import extends App.ControllerTabs header: 'Import' constructor: -> super - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'Import', true @tabs = [ { name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Import::Base' } } @@ -54,7 +54,7 @@ class Ticket extends App.ControllerTabs header: 'Ticket' constructor: -> super - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'Ticket', true @tabs = [ { name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Ticket::Base' } } diff --git a/app/assets/javascripts/app/controllers/sla.coffee b/app/assets/javascripts/app/controllers/sla.coffee index d098c2356..75f815912 100644 --- a/app/assets/javascripts/app/controllers/sla.coffee +++ b/app/assets/javascripts/app/controllers/sla.coffee @@ -9,7 +9,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') @interval(@load, 60000) #@load() diff --git a/app/assets/javascripts/app/controllers/translation.coffee b/app/assets/javascripts/app/controllers/translation.coffee index d9589d0c6..aa0791de7 100644 --- a/app/assets/javascripts/app/controllers/translation.coffee +++ b/app/assets/javascripts/app/controllers/translation.coffee @@ -8,7 +8,7 @@ class Index extends App.ControllerContent super # check authentication - return if !@authenticate() + return if !@authenticate(false, 'Admin') @title 'Translations', true @locale = App.i18n.get()