Created
May 22, 2010 00:52
-
-
Save legastero/409632 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __handleRegistration(self, iq): | |
if iq['type'] == 'get': | |
# Registration form requested | |
userData = self.backend[iq['from'].bare] | |
self.sendRegistrationForm(iq, userData) | |
elif iq['type'] == 'set': | |
if iq['register']['remove']: | |
# Remove an account | |
self.backend.unregister(iq['from'].bare) | |
self.xmpp.event('unregistered_user', iq) | |
iq.reply().send() | |
return | |
for field in self.form_fields: | |
if not iq['register'][field]: | |
# Incomplete Registration | |
self._sendError(iq, '406', 'modify', 'not-acceptable' | |
"Please fill in all fields.") | |
return | |
... | |
def _sendError(self, iq, code, error_type, name, text=''): | |
iq.reply().setPayload(iq['register'].xml) | |
iq.error() | |
iq['error']['code'] = code | |
iq['error']['type'] = error_type | |
iq['error']['condition'] = name | |
iq['error']['text'] = text | |
iq.send() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment