 
           return callback err  if err
 
-          {nickname}     = account.profile
+          { nickname }     = account.profile
 
           data           =
             name         : 'My Workspace'

    @remove callback


  @update: secure (client, id, options, callback)->

    selector   =
      originId : client.connection.delegate._id

    client.connection.delegate.fetchUser (err, user) ->
      return callback err  if err

      query = { 'users.id': user.getId() }

      JMachine.some query, {}, (err, machines) ->
        return callback err  if err

        machineUIds = machines.map (machine) -> machine.uid
        JWorkspace.some { machineUId: { $in: machineUIds } }, {}, callback


  @deleteById = secure (client, id, callback) ->

    selector   =
      originId : client.connection.delegate._id
      _id      : ObjectId id

    JWorkspace.one selector, (err, ws) ->
      return callback err  if err?
      unless ws
        callback new KodingError 'Workspace not found.'
      else
        ws.remove (err) -> callback err


  @deleteByUid = secure (client, uid, callback) ->

    selector     =
      originId   : client.connection.delegate._id
      machineUId : uid

    JWorkspace.remove selector, (err) ->
      callback err


  delete: secure (client, callback) ->

    { delegate } = client.connection

