         confirmation.send callback
 
   confirmEmail:(callback)-> @update {$set: status: 'confirmed'}, callback
-  block:(callback)-> @update {$set: status: 'blocked'}, callback
+
+  block:(blockedTo, callback)->
+    if blockedTo then return callback createKodingError "Blocking date is not defined"
+
+    @update
+      $set:
+        status: 'blocked',
+        blockedTo : blockedTo
+    , callback

      else unless user.getAt('password') is hashPassword password, user.getAt('salt')
        callback createKodingError 'Access denied!'
      else
        JSession.one {clientId}, (err, session)->
          if err
            callback err
          else unless session
            callback createKodingError 'Could not restore your session!'
          else
            replacementToken = createId()
            JGuest.recycle session.guestId
            session.update {
              $set            :
                username      : user.username
                lastLoginDate : new Date
                clientId      : replacementToken
              $unset:
                guestId       : 1
            }, (err)->
              if err
                callback err
              else
                if err
                  callback err
                else user.fetchOwnAccount (err, account)->
                  if err
                    callback err
                  else
                    connection.delegate = account
                    JAccount.emit "AccountAuthenticated", account

                    # This should be called after login and this
                    # is not correct place to do it, FIXME GG
                    # p.s. we could do that in workers
                    account.updateCounts()

                    callback null, account, replacementToken

  @logout = secure (client, callback)->
    if 'string' is typeof clientId


  @whoami = secure ({connection:{delegate}}, callback)-> callback delegate

  checkBlockedStatus = (user, callback)->
    if user.status is 'blocked'
      if user.blockedTo and user.blockedTo > new Date
        toDate = user.blockedTo.toUTCString()
        message = """
            You cannot login until #{toDate}.
            At least 10 moderators of Koding have decided that your participation is not of acceptable kind.
            That's all I know.
            You can demand further explanation from ban@koding.com. Please allow 1-2 days to receive a reply.
            Your machines might be blocked, all types of activities might be suspended.
            Your data is safe, you can access them when/if ban is lifted.
          """
        callback createKodingError message
      else
        user.update {$set: status: 'unconfirmed'}, callback
    else
      callback null

  @login = secure ({connection}, credentials, callback)->
    {username, password, clientId} = credentials
    constructor = @
    JUser.one {username}, (err, user)->
      if err
        callback createKodingError err.message
      else unless user?
