# HG changeset patch # User Adrien Di Mascio # Date 1243246697 -7200 # Node ID 864aa3ea0db5da9c8793253f177c665e04d53906 # Parent 7c266edf28bd1731fa59d24a1bbc095a2cd99005 [server] refactor server.utils.manager_userpasswd - remove passwd parameter which was never used - make the function usable when we have a login and want the user to enter a new password, with confirmation diff -r 7c266edf28bd -r 864aa3ea0db5 server/utils.py --- a/server/utils.py Fri May 22 01:31:21 2009 +0200 +++ b/server/utils.py Mon May 25 12:18:17 2009 +0200 @@ -63,23 +63,21 @@ DEFAULT_MSG = 'we need a manager connection on the repository \ (the server doesn\'t have to run, even should better not)' -def manager_userpasswd(user=None, passwd=None, msg=DEFAULT_MSG, confirm=False): +def manager_userpasswd(user=None, msg=DEFAULT_MSG, confirm=False, + passwdmsg='password'): if not user: print msg while not user: user = raw_input('login: ') - passwd = getpass('password: ') - if confirm: - while True: - passwd2 = getpass('confirm password: ') - if passwd == passwd2: - break - print 'password doesn\'t match' - passwd = getpass('password: ') user = unicode(user, sys.stdin.encoding) - elif not passwd: - assert not confirm - passwd = getpass('password for %s: ' % user) + passwd = getpass('%s: ' % passwdmsg) + if confirm: + while True: + passwd2 = getpass('confirm password: ') + if passwd == passwd2: + break + print 'password doesn\'t match' + passwd = getpass('password: ') # XXX decode password using stdin encoding then encode it using appl'encoding return user, passwd