 
   handleSwitch: (state) ->
 
-    allowedDomains = @state.team.get 'allowedDomains'
-    allowedDomains = allowedDomains.toJS()
+    unless @state.canEdit
+      return showError 'You are not allowed to toggle this button'
+
+    allowedDomains = @state.team?.get 'allowedDomains'
+    allowedDomains = allowedDomains?.toJS()
     allowedDomains = _.clone allowedDomains or []
 
     if state

React           = require 'kd-react'
View            = require './view'
TeamFlux        = require 'app/flux/teams'
KDReactorMixin  = require 'app/flux/base/reactormixin'
copyToClipboard = require 'app/util/copyToClipboard'


    return {
      team: TeamFlux.getters.team
    }

  constructor: (props) ->

    super props

    canEdit = kd.singletons.groupsController.canEditGroup()
    @state = {canEdit : canEdit}


  componentDidMount: ->
