import getpass

AUTH_TYPES = {'Gmail': 'OAuth', 'Yahoo': 'Password', 'EAS': 'Password'}


class AuthError(Exception):
    pass


def password_auth(email_address):
    pw = getpass.getpass('Password for %s (hidden): ' % email_address)

    if len(pw) <= 0:
        raise AuthError('Password required.')

    return dict(email=email_address, password=pw)

import getpass

AUTH_TYPES = {'Gmail': 'OAuth', 'Yahoo': 'Password', 'EAS': 'Password'}
message = 'Password for {0}(hidden): '


class AuthError(Exception):
    pass


def password_auth(email_address, message=message):
    pw = getpass.getpass(message.format(email_address))

    if len(pw) <= 0:
        raise AuthError('Password required.')

    return dict(email=email_address, password=pw)

Change for EAS invalid pw case, to allow user to re-enter pw once before raising error.
Change for EAS invalid pw case, to allow user to re-enter pw once before raising error.

Summary:
One line change in password_auth to allow password re-rentry.
See D106 too

Test Plan: None

Reviewers: mg

Differential Revision: https://review.inboxapp.com/D107

  import getpass
  
  AUTH_TYPES = {'Gmail': 'OAuth', 'Yahoo': 'Password', 'EAS': 'Password'}
+ message = 'Password for {0}(hidden): '
  
  
  class AuthError(Exception):
      pass
  
  
- def password_auth(email_address):
+ def password_auth(email_address, message=message):
-     pw = getpass.getpass('Password for %s (hidden): ' % email_address)
+     pw = getpass.getpass(message.format(email_address))
  
      if len(pw) <= 0:
          raise AuthError('Password required.')
  
      return dict(email=email_address, password=pw)
  
Change for EAS invalid pw case, to allow user to re-enter pw once before raising error.
## Code Before:
import getpass

AUTH_TYPES = {'Gmail': 'OAuth', 'Yahoo': 'Password', 'EAS': 'Password'}


class AuthError(Exception):
    pass


def password_auth(email_address):
    pw = getpass.getpass('Password for %s (hidden): ' % email_address)

    if len(pw) <= 0:
        raise AuthError('Password required.')

    return dict(email=email_address, password=pw)

## Instruction:
Change for EAS invalid pw case, to allow user to re-enter pw once before raising error.
## Code After:
import getpass

AUTH_TYPES = {'Gmail': 'OAuth', 'Yahoo': 'Password', 'EAS': 'Password'}
message = 'Password for {0}(hidden): '


class AuthError(Exception):
    pass


def password_auth(email_address, message=message):
    pw = getpass.getpass(message.format(email_address))

    if len(pw) <= 0:
        raise AuthError('Password required.')

    return dict(email=email_address, password=pw)
