plugins misc_account, misc_smtp: update the plugins that deal with passwords
This commit is contained in:
parent
0d28c03d27
commit
f3b0b52014
1 changed files with 27 additions and 18 deletions
|
|
@ -102,7 +102,7 @@ class ProsodyRegisterProtocol(protocol.ProcessProtocol):
|
|||
@param command: the command to execute: "adduser", "passwd" or "deluser"
|
||||
@param password: the user new password (leave to None for "deluser" command)
|
||||
@param profile: the user profile
|
||||
@return a Deferred instance
|
||||
@return: a Deferred instance
|
||||
"""
|
||||
d = defer.Deferred()
|
||||
prosody_reg = ProsodyRegisterProtocol(password, d)
|
||||
|
|
@ -161,12 +161,19 @@ class MiscAccount(object):
|
|||
if profile.lower() in self.getConfig('reserved_list'):
|
||||
return defer.fail(Failure(exceptions.ConflictError))
|
||||
|
||||
d = self.host.memory.asyncCreateProfile(profile)
|
||||
d = self.host.memory.asyncCreateProfile(profile, password)
|
||||
d.addCallback(self._profileRegistered, email, password, profile)
|
||||
return d
|
||||
|
||||
def _profileRegistered(self, result, email, password, profile):
|
||||
"""Create the profile and the XMPP account.
|
||||
|
||||
@param result: result of asyncCreateProfile
|
||||
@param email: user email
|
||||
@param password: chosen xmpp password
|
||||
@param profile: %(doc_profile)s
|
||||
@return: a deferred None value when all the processing is done
|
||||
"""
|
||||
#FIXME: values must be in a config file instead of hardcoded
|
||||
self.host.memory.setParam("JabberID", "%s@%s/%s" % (profile, self.getConfig('new_account_domain'), self.getConfig('new_account_resource')),
|
||||
"Connection", profile_key=profile)
|
||||
|
|
@ -176,8 +183,8 @@ class MiscAccount(object):
|
|||
"Connection", profile_key=profile)
|
||||
#and the account
|
||||
|
||||
#XXX: we use "prosodyctl adduser" because "register" doesn't check conflict
|
||||
# and just change the password if the account already exists
|
||||
# XXX: we use "prosodyctl adduser" because "register" doesn't check conflict
|
||||
# and just change the password if the account already exists
|
||||
d = ProsodyRegisterProtocol.prosodyctl(self, 'adduser', password, profile)
|
||||
d.addCallback(self._sendEmails, profile, email, password)
|
||||
d.addCallback(lambda ignore: None)
|
||||
|
|
@ -244,7 +251,7 @@ SàT team""" % {'login': login, 'password': password, 'jid': "%s@%s" % (login, s
|
|||
"""Get the main dialog to manage your account
|
||||
@param menu_data
|
||||
@param profile: %(doc_profile)s
|
||||
@return XML of the dialog
|
||||
@return: XML of the dialog
|
||||
"""
|
||||
form_ui = xml_tools.XMLUI("form", "tabs", title=D_("Manage your XMPP account"), submit_id=self.__account_cb_id)
|
||||
tab_container = form_ui.current_container
|
||||
|
|
@ -273,25 +280,26 @@ SàT team""" % {'login': login, 'password': password, 'jid': "%s@%s" % (login, s
|
|||
form_ui.addBool("delete_checkbox", "false")
|
||||
return form_ui.toXml()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _accountDialogCb(self, data, profile):
|
||||
"""Called when the user submits the main account dialog
|
||||
@param data
|
||||
@param profile
|
||||
"""
|
||||
password = self.host.memory.getParamA("Password", "Connection", profile_key=profile)
|
||||
password = yield self.host.memory.asyncGetParamA("Password", "Connection", profile_key=profile)
|
||||
|
||||
def error_ui():
|
||||
error_ui = xml_tools.XMLUI("popup", title=D_("Error"))
|
||||
error_ui.addText(D_("Passwords don't match!"))
|
||||
return defer.succeed({'xmlui': error_ui.toXml()})
|
||||
return {'xmlui': error_ui.toXml()}
|
||||
|
||||
# check for account deletion
|
||||
delete_passwd = data[xml_tools.SAT_FORM_PREFIX + 'delete_passwd']
|
||||
delete_checkbox = data[xml_tools.SAT_FORM_PREFIX + 'delete_checkbox']
|
||||
if delete_checkbox == 'true':
|
||||
if password == delete_passwd:
|
||||
return self.__deleteAccount(profile)
|
||||
return error_ui()
|
||||
defer.returnValue(self.__deleteAccount(profile))
|
||||
defer.returnValue(error_ui())
|
||||
|
||||
# check for blog posts deletion
|
||||
if 'GROUPBLOG' in self.host.plugins:
|
||||
|
|
@ -302,8 +310,8 @@ SàT team""" % {'login': login, 'password': password, 'jid': "%s@%s" % (login, s
|
|||
comments = delete_comments_checkbox == 'true'
|
||||
if posts or comments:
|
||||
if password == delete_posts_passwd:
|
||||
return self.__deleteBlogPosts(posts, comments, profile)
|
||||
return error_ui()
|
||||
defer.returnValue(self.__deleteBlogPosts(posts, comments, profile))
|
||||
defer.returnValue(error_ui())
|
||||
|
||||
# check for password modification
|
||||
current_passwd = data[xml_tools.SAT_FORM_PREFIX + 'current_passwd']
|
||||
|
|
@ -311,10 +319,11 @@ SàT team""" % {'login': login, 'password': password, 'jid': "%s@%s" % (login, s
|
|||
new_passwd2 = data[xml_tools.SAT_FORM_PREFIX + 'new_passwd2']
|
||||
if new_passwd1 or new_passwd2:
|
||||
if password == current_passwd and new_passwd1 == new_passwd2:
|
||||
return self.__changePassword(new_passwd1, profile=profile)
|
||||
return error_ui()
|
||||
data = yield self.__changePassword(new_passwd1, profile=profile)
|
||||
defer.returnValue(data)
|
||||
defer.returnValue(error_ui())
|
||||
|
||||
return defer.succeed({})
|
||||
defer.returnValue({})
|
||||
|
||||
def __changePassword(self, password, profile):
|
||||
"""Actually change the user XMPP account and SàT profile password
|
||||
|
|
|
|||
Loading…
Reference in a new issue