   m = addr.match matchEmail
   m isnt null
 
-tryOneToken = (ddp, options, cb) ->
-  ddp.call 'login', [{ resume: process.env[options.env] }], (err, res) ->
-    return cb err, res?.token
 
 attemptLogin = (ddp, user, pass, options, cb) ->
-  hash = crypto.createHash 'sha256'
-  hash.update pass, 'utf8'
-  digest = { digest: hash.digest('hex'), algorithm: 'sha-256' }
+  digest = plaintextToDigest pass
   ddp.call 'login', [{user: user, password: digest}], (err, res) ->
     unless err and err.error is 400 and options.plaintext
       if err

tryOneEmail = (ddp, options, cb) ->
  userPrompt "Email: ", options, (err, res) ->
    return cb err if err
    attemptLogin ddp, {email: res.account}, res.pass, options, cb

tryOneUser = (ddp, options, cb) ->
  userPrompt "Username: ", options, (err, res) ->
    return cb err if err
    attemptLogin ddp, {user: res.account}, res.pass, options, cb

tryOneEither = (ddp, options, cb) ->
  userPrompt "Account: ", options, (err, res) ->
    return cb err if err
    if isEmail res.account
      attemptLogin ddp, {email: res.account}, res.pass, options, (err, tok) ->
        return cb err, tok unless err and err.error is 400
        attemptLogin ddp, {user: res.account}, res.pass, options, cb
    else
      attemptLogin ddp, {user: res.account}, res.pass, options, cb

#
# When run standalone, the code below will execute

        return async.retry options.retry, async.apply(method, ddp, options), cb
  else
    return async.retry options.retry, async.apply(method, ddp, options), cb

plaintextToDigest = (pass) ->
  hash = crypto.createHash 'sha256'
  hash.update pass, 'utf8'
  return { digest: hash.digest('hex'), algorithm: 'sha-256' }

isEmail = (addr) ->
  unless typeof addr is 'string'
