Improved permission check in fronted.
This commit is contained in:
parent
fb5927eeaf
commit
3f0685a450
19 changed files with 36 additions and 30 deletions
|
@ -202,7 +202,13 @@ class App.Controller extends Spine.Controller
|
||||||
callback: data.callback
|
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 exists
|
||||||
return true if @Session.get()
|
return true if @Session.get()
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Index extends App.ControllerContent
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
#@interval(@load, 60000)
|
#@interval(@load, 60000)
|
||||||
@load()
|
@load()
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Index extends App.ControllerContent
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
#@interval(@load, 60000)
|
#@interval(@load, 60000)
|
||||||
@load()
|
@load()
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Index extends App.Controller
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Agent')
|
||||||
@title 'Notifications', true
|
@title 'Notifications', true
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class App.TicketCreate extends App.Controller
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
if !@authenticate()
|
if !@authenticate(false, 'Agent')
|
||||||
App.TaskManager.remove(@task_key)
|
App.TaskManager.remove(@task_key)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
@interval(@load, 60000)
|
@interval(@load, 60000)
|
||||||
#@load()
|
#@load()
|
||||||
|
|
|
@ -316,7 +316,7 @@ class CustomerChatRouter extends App.ControllerPermanent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Chat')
|
||||||
|
|
||||||
App.TaskManager.execute(
|
App.TaskManager.execute(
|
||||||
key: 'CustomerChat'
|
key: 'CustomerChat'
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Customer')
|
||||||
|
|
||||||
# set title
|
# set title
|
||||||
@title 'New Ticket'
|
@title 'New Ticket'
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.ControllerContent
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
||||||
if @authenticate(true)
|
if @authenticate(true, 'Admin')
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class AutoWizard extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# if already logged in, got to #
|
# if already logged in, got to #
|
||||||
if @authenticate(true)
|
if @authenticate(true, 'Admin')
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ class Admin extends App.ControllerContent
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
|
||||||
if @authenticate(true)
|
if @authenticate(true, 'Admin')
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ class Base extends App.Wizard
|
||||||
super
|
super
|
||||||
|
|
||||||
# redirect if we are not admin
|
# redirect if we are not admin
|
||||||
if !@authenticate(true)
|
if !@authenticate(true, 'Admin')
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ class EmailNotification extends App.Wizard
|
||||||
super
|
super
|
||||||
|
|
||||||
# redirect if we are not admin
|
# redirect if we are not admin
|
||||||
if !@authenticate(true)
|
if !@authenticate(true, 'Admin')
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ class Channel extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# redirect if we are not admin
|
# redirect if we are not admin
|
||||||
if !@authenticate(true)
|
if !@authenticate(true, 'Admin')
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ class ChannelEmailPreConfigured extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# redirect if we are not admin
|
# redirect if we are not admin
|
||||||
if !@authenticate(true)
|
if !@authenticate(true, 'Admin')
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ class ChannelEmail extends App.Wizard
|
||||||
super
|
super
|
||||||
|
|
||||||
# redirect if we are not admin
|
# redirect if we are not admin
|
||||||
if !@authenticate(true)
|
if !@authenticate(true, 'Admin')
|
||||||
@navigate '#'
|
@navigate '#'
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
new App.ControllerGenericIndex(
|
new App.ControllerGenericIndex(
|
||||||
el: @el
|
el: @el
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
new App.ControllerGenericIndex(
|
new App.ControllerGenericIndex(
|
||||||
el: @el
|
el: @el
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
@title 'Maintenance', true
|
@title 'Maintenance', true
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Index extends App.ControllerTabs
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
@title 'Objects', true
|
@title 'Objects', true
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
new App.ControllerGenericIndex(
|
new App.ControllerGenericIndex(
|
||||||
el: @el
|
el: @el
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
@title 'Packages', true
|
@title 'Packages', true
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
@title 'Sessions', true
|
@title 'Sessions', true
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Branding extends App.ControllerTabs
|
||||||
header: 'Branding'
|
header: 'Branding'
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
@title 'Branding', true
|
@title 'Branding', true
|
||||||
@tabs = [
|
@tabs = [
|
||||||
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'System::Branding' } }
|
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'System::Branding' } }
|
||||||
|
@ -13,7 +13,7 @@ class System extends App.ControllerTabs
|
||||||
header: 'System'
|
header: 'System'
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
@title 'System', true
|
@title 'System', true
|
||||||
@tabs = []
|
@tabs = []
|
||||||
if !App.Config.get('system_online_service')
|
if !App.Config.get('system_online_service')
|
||||||
|
@ -28,7 +28,7 @@ class Security extends App.ControllerTabs
|
||||||
header: 'Security'
|
header: 'Security'
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
@title 'Security', true
|
@title 'Security', true
|
||||||
@tabs = [
|
@tabs = [
|
||||||
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Security::Base' } }
|
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Security::Base' } }
|
||||||
|
@ -42,7 +42,7 @@ class Import extends App.ControllerTabs
|
||||||
header: 'Import'
|
header: 'Import'
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
@title 'Import', true
|
@title 'Import', true
|
||||||
@tabs = [
|
@tabs = [
|
||||||
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Import::Base' } }
|
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Import::Base' } }
|
||||||
|
@ -54,7 +54,7 @@ class Ticket extends App.ControllerTabs
|
||||||
header: 'Ticket'
|
header: 'Ticket'
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
@title 'Ticket', true
|
@title 'Ticket', true
|
||||||
@tabs = [
|
@tabs = [
|
||||||
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Ticket::Base' } }
|
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Ticket::Base' } }
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
@interval(@load, 60000)
|
@interval(@load, 60000)
|
||||||
#@load()
|
#@load()
|
||||||
|
|
|
@ -8,7 +8,7 @@ class Index extends App.ControllerContent
|
||||||
super
|
super
|
||||||
|
|
||||||
# check authentication
|
# check authentication
|
||||||
return if !@authenticate()
|
return if !@authenticate(false, 'Admin')
|
||||||
|
|
||||||
@title 'Translations', true
|
@title 'Translations', true
|
||||||
@locale = App.i18n.get()
|
@locale = App.i18n.get()
|
||||||
|
|
Loading…
Reference in a new issue