changeset 3069:15d744f727c9

UserPreferences 'send account data' also accepts username now (not only email addr), thanks to Joel Nackman (ported from 1.6)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 22 Feb 2008 18:31:22 +0100
parents 5471f4a009dc
children ed1a433803c6
files MoinMoin/action/recoverpass.py MoinMoin/user.py
diffstat 2 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/recoverpass.py	Fri Feb 22 18:11:05 2008 +0100
+++ b/MoinMoin/action/recoverpass.py	Fri Feb 22 18:31:22 2008 +0100
@@ -18,12 +18,26 @@
 Contact the owner of the wiki, who can enable email.""")
     try:
         email = wikiutil.clean_input(form['email'][0].lower())
+        if not email:
+            raise KeyError # we raise KeyError if the string is empty
     except KeyError:
-        return _("Please provide a valid email address!")
+        try:
+            username = wikiutil.clean_input(form['name'][0])
+            if not username:
+                raise KeyError
+        except KeyError:
+            return _("Please provide a valid email address!", formatted=False)
+
+        u = user.User(self.request, user.getUserId(self.request, username))
+        if u.valid:
+            is_ok, msg = u.mailAccountData()
+            if not is_ok:
+                return wikiutil.escape(msg)
+        return _("If an account with this username exists, an email was sent.", formatted=False)
 
     u = user.get_by_email_address(request, email)
     if u:
-        msg = u.mailAccountData()
+        is_ok, msg = u.mailAccountData()
         return wikiutil.escape(msg)
 
     return _("Found no account matching the given email address '%(email)s'!") % {'email': email}
--- a/MoinMoin/user.py	Fri Feb 22 18:11:05 2008 +0100
+++ b/MoinMoin/user.py	Fri Feb 22 18:31:22 2008 +0100
@@ -1054,5 +1054,5 @@
                     formatted=False) % {'sitename': self._cfg.sitename or "Wiki"}
         mailok, msg = sendmail.sendmail(self._request, [self.email], subject,
                                     text, mail_from=self._cfg.mail_from)
-        return msg
+        return mailok, msg