[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
--- 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