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
|
||||
)
|
||||
|
||||
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()
|
||||
|
|
|
@ -7,7 +7,7 @@ class Index extends App.ControllerContent
|
|||
|
||||
constructor: ->
|
||||
super
|
||||
return if !@authenticate()
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
#@interval(@load, 60000)
|
||||
@load()
|
||||
|
|
|
@ -7,7 +7,7 @@ class Index extends App.ControllerContent
|
|||
|
||||
constructor: ->
|
||||
super
|
||||
return if !@authenticate()
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
#@interval(@load, 60000)
|
||||
@load()
|
||||
|
|
|
@ -45,7 +45,7 @@ class Index extends App.Controller
|
|||
|
||||
constructor: ->
|
||||
super
|
||||
return if !@authenticate()
|
||||
return if !@authenticate(false, 'Agent')
|
||||
@title 'Notifications', true
|
||||
@render()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class Index extends App.ControllerContent
|
|||
super
|
||||
|
||||
# check authentication
|
||||
return if !@authenticate()
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
@interval(@load, 60000)
|
||||
#@load()
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,7 +6,7 @@ class Index extends App.ControllerContent
|
|||
super
|
||||
|
||||
# check authentication
|
||||
return if !@authenticate()
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
@title 'Maintenance', true
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ class Index extends App.ControllerTabs
|
|||
super
|
||||
|
||||
# check authentication
|
||||
return if !@authenticate()
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
@title 'Objects', true
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,7 +6,7 @@ class Index extends App.ControllerContent
|
|||
super
|
||||
|
||||
# check authentication
|
||||
return if !@authenticate()
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
@title 'Packages', true
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class Index extends App.ControllerContent
|
|||
super
|
||||
|
||||
# check authentication
|
||||
return if !@authenticate()
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
@title 'Sessions', true
|
||||
|
||||
|
|
|
@ -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' } }
|
||||
|
|
|
@ -9,7 +9,7 @@ class Index extends App.ControllerContent
|
|||
super
|
||||
|
||||
# check authentication
|
||||
return if !@authenticate()
|
||||
return if !@authenticate(false, 'Admin')
|
||||
|
||||
@interval(@load, 60000)
|
||||
#@load()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue