     promise
 
   login : () =>
-
     if @isAuthenticating()
       # Return promise even if login is in progress.
       msg = "Login in progress. Use `Hull.on('hull.user.login', callback)` to call `callback` when done."

    @completeLoginPromiseChain(promise,callback,errback)

  completeLoginPromiseChain: (promise, callback,errback)=>
    callback = callback || -> 
    errback  = errback  || -> 

    p = promise.then @api.refreshUser, @emitLoginFailure
    p.then callback, errback

      # Hull.login({login:'user@host.com', password:'xxxx'})
      # Hull.login({access_token:'xxxxx'})

      if options.strategy == 'redirect'
        return postForm(@config.orgUrl+'/api/v1/users/login', 'post', options)

      promise = @api.message('users/login', 'post', _.pick(options, 'login', 'password', 'access_token'))

    @completeLoginPromiseChain(promise,callback,errback)
