changeset 416:fb5e1ecdbc33

generate rnd password when there is none yet imported from: moin--main--1.5--patch-420
author Thomas Waldmann <tw@waldmann-edv.de>
date Fri, 03 Feb 2006 20:41:07 +0000
parents 6da5739cbe0c
children 2b21d2ea1b3e
files ChangeLog MoinMoin/user.py docs/CHANGES
diffstat 3 files changed, 36 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Feb 03 20:30:15 2006 +0000
+++ b/ChangeLog	Fri Feb 03 20:41:07 2006 +0000
@@ -2,6 +2,20 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-02-03 21:41:07 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-420
+
+    Summary:
+      generate rnd password when there is none yet
+    Revision:
+      moin--main--1.5--patch-420
+
+    generate rnd password when there is none yet
+    
+
+    modified files:
+     ChangeLog MoinMoin/user.py docs/CHANGES
+
+
 2006-02-03 21:30:15 GMT	Alexander Schremmer <alex@alexanderweb.de.tla>	patch-419
 
     Summary:
--- a/MoinMoin/user.py	Fri Feb 03 20:30:15 2006 +0000
+++ b/MoinMoin/user.py	Fri Feb 03 20:41:07 2006 +0000
@@ -933,16 +933,31 @@
 
     def mailAccountData(self, cleartext_passwd=None):
         from MoinMoin.util import mail
+        from MoinMoin.wikiutil import getSysPage
         _ = self._request.getText
 
+        if not self.enc_password: # generate pw if there is none yet
+            from random import randint
+            import base64
+    
+            charset = 'utf-8'
+            pwd = "%s%d" % (str(time.time()), randint(0, 65535))
+            pwd = pwd.encode(charset)
+
+            pwd = sha.new(pwd).digest()
+            pwd = '{SHA}%s' % base64.encodestring(pwd).rstrip()
+    
+            self.enc_password = pwd
+            self.save()
+
         text = '\n' + _("""\
 Login Name: %s
 
 Login Password: %s
 
-Login URL: %s/?action=userform&uid=%s
+Login URL: %s/%s
 """, formatted=False) % (
-                        self.name, self.enc_password, self._request.getBaseURL(), self.id)
+                        self.name, self.enc_password, self._request.getBaseURL(), getSysPage(self._request, 'UserPreferences').page_name)
 
         text = _("""\
 Somebody has requested to submit your account data to this email address.
@@ -960,4 +975,4 @@
         mailok, msg = mail.sendmail(self._request, [self.email], subject,
                                     text, mail_from=self._cfg.mail_from)
         return msg
-        
+
--- a/docs/CHANGES	Fri Feb 03 20:30:15 2006 +0000
+++ b/docs/CHANGES	Fri Feb 03 20:41:07 2006 +0000
@@ -15,11 +15,13 @@
     * deron meranda's formatter API cleanup
     * added div and span to formatter API
     * allow hex and symbolic entities
-    * Removed old unfinished form and export code.
+    * removed old unfinished form and export code.
+    * if there is a user with empty password, we just generate a random one
+      when he requests it getting sent by mail. Thanks to Reimar Bauer.
 
   Fixes:
    * fixed table attribute parsing
-   * Fixed cookie handling wrt properties adherance.
+   * fixed cookie handling wrt properties adherance.
    * the new "." markup makes it possible to have a bulletless list with
      elements on the same level. Before this change and only using indentation
      with blanks, that would get merged into a single paragraph.