 
 exports.getAllMediators = ->
   # Must be admin
-  if authorisation.inGroup('admin', @authenticated) is false
-    utils.logAndSetResponse this, 'forbidden', "User #{@authenticated.email} is not an admin, API access to getAllMediators denied.", 'info'
+  if not authorisation.inGroup 'admin', this.authenticated
+    utils.logAndSetResponse this, 'forbidden', "User #{this.authenticated.email} is not an admin, API access to getAllMediators denied.", 'info'
     return
 
   try
-    @body = yield Mediator.find().exec()
+    this.body = yield Mediator.find().exec()
   catch err
     logAndSetResponse this, 'internal server error', "Could not fetch mediators via the API: #{err}", 'error'
 


exports.addMediator = ->
  # Must be admin
  if authorisation.inGroup('admin', @authenticated) is false
    utils.logAndSetResponse this, 'forbidden', "User #{@authenticated.email} is not an admin, API access to addMediator denied.", 'info'
    return

  try
    mediator = @request.body
    if !mediator.urn
      throw
        name: 'ValidationError'

      yield Q.ninvoke(new Mediator(mediator), 'save')
      if mediator.defaultChannelConfig
        yield saveDefaultChannelConfig(mediator.defaultChannelConfig);
    this.status = 'created'
    logger.info "User #{this.authenticated.email} created mediator with urn #{mediator.urn}"
  catch err
    if err.name == 'ValidationError'
      utils.logAndSetResponse this, 'bad request', "Could not add Mediator via the API: #{err}", 'error'
