changeset 2205:90ef29715d9e

merged main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 15 Oct 2013 21:04:06 -0700
parents c574f206f39f (current diff) ed73c69d80c0 (diff)
children 85840f06e1ac
files
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/account/resetpw.py	Mon Sep 23 20:51:49 2013 +0200
+++ b/MoinMoin/script/account/resetpw.py	Tue Oct 15 21:04:06 2013 -0700
@@ -13,7 +13,9 @@
 from flask import current_app as app
 from flask.ext.script import Command, Option
 
-from MoinMoin.constants.keys import ITEMID, NAME, NAME_EXACT, EMAIL
+from MoinMoin.constants.keys import (
+    ITEMID, NAME, NAME_EXACT, EMAIL, EMAIL_UNVALIDATED,
+)
 from MoinMoin import user
 from MoinMoin.app import before_wiki
 
@@ -41,9 +43,9 @@
             return
         u.set_password(password)
         u.save()
-        if not u.email:
-            raise UserHasNoEMail('User profile does not have an E-Mail address (name: %r id: %r)!' % (u.name, u.id))
         if notify and not u.disabled:
+            if not u.email:
+                raise UserHasNoEMail('Notification was requested, but User profile does not have a validated E-Mail address (name: %r id: %r)!' % (u.name, u.itemid))
             mailok, msg = u.mail_password_recovery(subject=subject, text=text)
             if not mailok:
                 raise MailFailed(msg)
@@ -103,7 +105,13 @@
         total = len(uids_metas)
         for nr, (uid, meta) in enumerate(uids_metas, start=1):
             name = meta[NAME]
-            email = meta[EMAIL]
+            email = meta.get(EMAIL)
+            if email is None:
+                email = meta.get(EMAIL_UNVALIDATED)
+                if email is None:
+                    raise ValueError("neither EMAIL nor EMAIL_UNVALIDATED key is present in user profile metadata of uid %r name %r" % (uid, name))
+                else:
+                    email += '[email_unvalidated]'
             try:
                 set_password(uid, password, notify=notify, skip_invalid=skip_invalid,
                              subject=subject, text=text)