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
elif self.pwd: pass
else:
try:
self.pwd = getpass.getpass(colorize(_('Admin Password: '), 'yellow'))
except KeyboardInterrupt, EOFError:
raise YunoHostError(125, _("Interrupted"))
need_password = True
while need_password:
try:
self.pwd = getpass.getpass(colorize(_('Admin Password: '), 'yellow'))
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
except KeyboardInterrupt, EOFError:
raise YunoHostError(125, _("Interrupted"))
except ldap.INVALID_CREDENTIALS:
pass
else:
need_password = False
self.level = self.level+1
try: