Actually added working password reset functions. Fixed views as required.

This commit is contained in:
2010-03-18 18:16:18 +00:00
parent 606ddd3cd7
commit 42588e1909
5 changed files with 37 additions and 2 deletions

View File

@@ -63,4 +63,12 @@ class JabberService(BaseService):
username, server = uid.split("@")
return self.ejctl.enable_user(server, username, password)
def reset_password(self, uid, password):
""" Reset the user's password """
if self.method == "xmpp":
return self.jabberadmin.resetpassword(uid, password)
else:
username, server = uid.split("@")
return self.ejctl.set_password(server, username, password)
ServiceClass = 'JabberService'

View File

@@ -87,6 +87,25 @@ class JabberAdmin():
else:
return False
def resetpassword(self, username, password):
# Send request and get the Session ID
resp = self._client.SendAndWaitForResponse(self._construct_iq_req('http://jabber.org/protocol/commands', 'http://jabber.org/protocol/admin#change-user-password'))
sessionid = resp.getTagAttr('command','sessionid')
values = [ ('hidden', 'FORM_TYPE', 'http://jabber.org/protocol/admin'),
('jid-single', 'accountjid', username),
('text-private', 'password', password) ]
iq = self._construct_form('http://jabber.org/protocol/commands', 'http://jabber.org/protocol/admin#change-user-password', sessionid, values)
# Send request and pray for the best
resp = self._client.SendAndWaitForResponse(iq)
if resp.getAttrs()['type'] == "result":
return True
else:
return False
def checkuser(self, username):
# Send request and get the Session ID