- implemented change pop/imap password
git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@136 a67ec6bc-e5d5-0310-a910-815c51eb3124
This commit is contained in:
parent
cab6f70ec8
commit
da5aa67ac9
2 changed files with 69 additions and 2 deletions
|
@ -143,12 +143,20 @@ Password: %(password)s""" % {'domain': self.domain,
|
|||
|
||||
def hasPopUser(self, username):
|
||||
"""Checks whether the specified POP3/IMAP user exists in the domain."""
|
||||
return ([user for user in domain.listPopUsers() if (user == username)])
|
||||
return ([user for user in self.listPopUsers() if (user == username)])
|
||||
|
||||
def updatePopPassword(self, username, password=PasswordTools.generate_password()):
|
||||
"""Updates the password of the given POP3/IMAP user."""
|
||||
if self.hasPopUser(username):
|
||||
print("will update password of user %s to %s" % (username, password))
|
||||
crypted = PasswordTools.md5_crypt_password(password)
|
||||
|
||||
cr = self.cnx.cursor()
|
||||
cr.execute("UPDATE mailpasswd SET clear=%(clear)s, crypt=%(crypt)s WHERE id=%(user)s" % {
|
||||
'clear': psycopg.QuotedString(password),
|
||||
'crypt': psycopg.QuotedString(crypted),
|
||||
'user': psycopg.QuotedString(username)})
|
||||
self.cnx.commit()
|
||||
print("updated password of user %s to %s" % (username, password))
|
||||
else:
|
||||
raise InvalidPopUser(self, username)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue