Mercurial > public > src > moin > 1.9
diff MoinMoin/user.py @ 5936:2d3352c547bc
moin account resetpw - misc. improvements
add some options to define email subject and text, either by commandline
arguments or by reading an email template from a text file.
added instructions about how to deal with a password reset and a email
template, see docs/resetpw/
if notificiation is requested and the wiki is not configured for email
sending, abort.
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Thu, 24 Jan 2013 22:34:41 +0100 |
parents | aac944a51a54 |
children | 24054d620fc1 |
line wrap: on
line diff
--- a/MoinMoin/user.py Thu Jan 24 14:25:48 2013 +0100 +++ b/MoinMoin/user.py Thu Jan 24 22:34:41 2013 +0100 @@ -191,7 +191,9 @@ """raised if e-mail sending failed""" -def set_password(request, newpass, u=None, uid=None, uname=None, notify=False): +def set_password(request, newpass, u=None, uid=None, uname=None, + notify=False, subject=None, + text_intro=None, text_msg=None, text_data=None): if uid: u = User(request, uid) elif uname: @@ -204,7 +206,8 @@ u.enc_password = encodePassword(request.cfg, newpass) u.save() if notify and not u.disabled: - mailok, msg = u.mailAccountData() + mailok, msg = u.mailAccountData(subject=subject, + text_intro=text_intro, text_msg=text_msg, text_data=text_data) if not mailok: raise MailFailed(msg) else: @@ -1111,12 +1114,13 @@ self.save() return True - def mailAccountData(self, cleartext_passwd=None): + def mailAccountData(self, cleartext_passwd=None, + subject=None, + text_intro=None, text_msg=None, text_data=None): """ Mail a user who forgot his password a message enabling him to login again. """ from MoinMoin.mail import sendmail - from MoinMoin.wikiutil import getLocalizedPage _ = self._request.getText if not self.email: @@ -1124,30 +1128,35 @@ tok = self.generate_recovery_token() - text = '\n' + _("""\ + if subject is None: + subject = _('[%(sitename)s] Your wiki account data') + subject = subject % dict(sitename=self._cfg.sitename or "Wiki") + if text_intro is None: + text_intro = '' + if text_msg is None: + text_msg = """\ +Somebody has requested to email you a password recovery token. + +If you lost your password, please go to the password reset URL below or +go to the password recovery page again and enter your username and the +recovery token. +""" + if text_data is None: + text_data = """\ Login Name: %s Password recovery token: %s Password reset URL: %s?action=recoverpass&name=%s&token=%s -""") % ( +""" + # note: text_intro is for custom stuff, we do not have i18n for it anyway + text = text_intro + '\n' + _(text_msg) + '\n' + _(text_data) % ( self.name, tok, self._request.url, # use full url, including current page url_quote_plus(self.name), tok, ) - text = _("""\ -Somebody has requested to email you a password recovery token. - -If you lost your password, please go to the password reset URL below or -go to the password recovery page again and enter your username and the -recovery token. -""") + text - - - subject = _('[%(sitename)s] Your wiki account data', - ) % {'sitename': self._cfg.sitename or "Wiki"} mailok, msg = sendmail.sendmail(self._request, [self.email], subject, text, mail_from=self._cfg.mail_from) return mailok, msg