 
   # Test if the user is authorised
   if not authorisation.inGroup 'admin', this.authenticated
-    logger.info "User #{this.authenticated.email} is not an admin, API access to findClientByDomain denied."
-    this.body = "User #{this.authenticated.email} is not an admin, API access to findClientByDomain denied."
-    this.status = 'forbidden'
+    utils.logAndSetResponse this, 'forbidden', "User #{this.authenticated.email} is not an admin, API access to findClientByDomain denied.", 'info'
     return
 
   clientDomain = unescape clientDomain

    client = new Client clientData
    result = yield Q.ninvoke client, 'save'
    
    this.body = 'Client successfully created'
    this.status = 'created'
    logger.info "User #{this.authenticated.email} created client with id #{client.id}"
  catch e
    logger.error "Could not add a client via the API: #{e.message}"
    this.body = e.message

  try
    result = yield Client.findOne(clientDomain: clientDomain).exec()
    if result is null
      utils.logAndSetResponse this, 'not found', "Could not find client with clientDomain #{clientDomain}", 'info'
    else
      this.body = result
  catch e
