changeset 3563:8140f31ada6d

recoverpass: consolidate mail sending
author Johannes Berg <johannes AT sipsolutions DOT net>
date Thu, 24 Apr 2008 15:20:15 +0200
parents 58a97376342c
children 474f6ad01900
files MoinMoin/action/recoverpass.py
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/recoverpass.py	Thu Apr 24 15:16:08 2008 +0200
+++ b/MoinMoin/action/recoverpass.py	Thu Apr 24 15:20:15 2008 +0200
@@ -10,6 +10,17 @@
 from MoinMoin.Page import Page
 from MoinMoin.widget import html
 
+def _do_email(request, u):
+    _ = request.getText
+
+    if u and u.valid:
+        is_ok, msg = u.mailAccountData()
+        if not is_ok:
+            return wikiutil.escape(msg)
+
+    return _("If this account exists an email was sent.")
+
+
 def _do_recover(request):
     _ = request.getText
     form = request.form
@@ -24,12 +35,8 @@
             raise KeyError
 
         u = user.get_by_email_address(request, email)
-        if u and u.valid:
-            is_ok, msg = u.mailAccountData()
-            if not is_ok:
-                return wikiutil.escape(msg)
 
-        return _("If an account with this email address exists, an email was sent.")
+        return _do_email(request, u)
     except KeyError:
         pass
 
@@ -40,12 +47,8 @@
             raise KeyError
 
         u = user.User(request, user.getUserId(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.")
+        return _do_email(request, u)
     except KeyError:
         pass