Ask for password again if it fails

This commit is contained in:
Kload 2013-06-15 16:10:45 +02:00
parent 509a3a7f78
commit 576e2eb7ef

View file

@ -282,10 +282,17 @@ class YunoHostLDAP(Singleton):
if password: self.pwd = password if password: self.pwd = password
elif self.pwd: pass elif self.pwd: pass
else: else:
need_password = True
while need_password:
try: try:
self.pwd = getpass.getpass(colorize(_('Admin Password: '), 'yellow')) self.pwd = getpass.getpass(colorize(_('Admin Password: '), 'yellow'))
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
except KeyboardInterrupt, EOFError: except KeyboardInterrupt, EOFError:
raise YunoHostError(125, _("Interrupted")) raise YunoHostError(125, _("Interrupted"))
except ldap.INVALID_CREDENTIALS:
pass
else:
need_password = False
self.level = self.level+1 self.level = self.level+1
try: try: