     return new KodingError "Key is not valid" unless @authCheckKey key
     return new KodingError "Data is not valid" unless username and hostname
 
-    @fetchByUserKey {username, key}, (err, kodingKey)=>
-      return callback new KodingError "Koding Auth Error - 3" if err
+    JKodingKey.one {key:key}, (err, kodingKey)=>
+      if err
+        console.warn "Error occured while fetching koding-key username: #{username}, key: #{key}, err :#{err}"
+        return callback new KodingError "There is a problem with your key"
+
       if kodingKey
         errMessage = "Authentication already established with #{kodingKey.hostname}!"
         return callback new KodingError errMessage
 
       # if not created before, create here
-      @createKeyByUser {username, hostname, key}, (err, data)=>
-        return callback new KodingError "Koding Auth Error - 3" if err
+      JKodingKey.createKeyByUser {username, hostname, key}, (err, data)=>
+        if err
+          console.warn "Error occured while creating koding key - Err: #{err}, "
+          return callback new KodingError "An error occured while saving your key, please try again later"
         return callback null, "Authentication is successfull! Using id: #{data.hostname}"

    , (err, keys)->
      callback err, keys

  # TODO: Do not use username. Use secure instead.
  @fetchByUserKey = (options, callback)->
    JAccount.one
      'profile.nickname': options.username
    , (err, account)->
      if err then callback err
      else if not account
        callback null, null
      else
        JKodingKey.one
          key   : options.key
          owner : account._id
        , (err, key)->
          callback err, key

  @fetchKey = (options, callback)->
    JKodingKey.one
      key   : options.key
    , (err, key)->
      callback err, key

  @fetchByKeyAndHostname = (options, callback)->
    JKodingKey.one
      owner : delegate.getId()
      key   : options.key
      hostname: options.hostname
    , (err, keys)->
      callback err, keys

  @createKeyByUser = (options, callback)->
    JAccount.one

    , (err, key)->
      key.remove callback

  @authCheckKey = (key)->
    return false if not key
    return false if typeof key isnt "string"

