Skip to content

Commit 00af9aa

Browse files
author
Richard Jones
committed
set new email rego user password to random string
1 parent 5fe3c87 commit 00af9aa

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

roundup/cgi/client.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.112 2003-04-10 04:32:46 richard Exp $
1+
# $Id: client.py,v 1.113 2003-04-10 05:12:41 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -31,6 +31,8 @@ class NotModified(HTTPException):
3131
# this var must contain a file to write the mail to
3232
SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '')
3333

34+
# used by a couple of routines
35+
chars = string.letters+string.digits
3436

3537
# XXX actually _use_ FormError
3638
class FormError(ValueError):
@@ -694,7 +696,6 @@ def logout_action(self):
694696
# Let the user know what's going on
695697
self.ok_message.append(_('You are logged out'))
696698

697-
chars = string.letters+string.digits
698699
def registerAction(self):
699700
'''Attempt to create a new user based on the contents of the form
700701
and then set the cookie.
@@ -721,7 +722,7 @@ def registerAction(self):
721722
pass
722723

723724
# generate the one-time-key and store the props for later
724-
otk = ''.join([random.choice(self.chars) for x in range(32)])
725+
otk = ''.join([random.choice(chars) for x in range(32)])
725726
for propname, proptype in self.db.user.getprops().items():
726727
value = props.get(propname, None)
727728
if value is None:
@@ -885,7 +886,7 @@ def passResetAction(self):
885886
self.opendb('admin')
886887

887888
# change the password
888-
newpw = ''.join([random.choice(self.chars) for x in range(8)])
889+
newpw = password.generatePassword()
889890

890891
cl = self.db.user
891892
# XXX we need to make the "default" page be able to display errors!
@@ -939,7 +940,7 @@ def passResetAction(self):
939940
return
940941

941942
# generate the one-time-key and store the props for later
942-
otk = ''.join([random.choice(self.chars) for x in range(32)])
943+
otk = ''.join([random.choice(chars) for x in range(32)])
943944
self.db.otks.set(otk, uid=uid, __time=time.time())
944945

945946
# send the email

roundup/mailgw.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,14 @@ class node. Any parts of other types are each stored in separate files
7373
an exception, the original message is bounced back to the sender with the
7474
explanatory message given in the exception.
7575
76-
$Id: mailgw.py,v 1.113 2003-03-24 02:54:35 richard Exp $
76+
$Id: mailgw.py,v 1.114 2003-04-10 05:12:41 richard Exp $
7777
'''
7878

7979
import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri
8080
import time, random, sys
8181
import traceback, MimeWriter, rfc822
82-
import hyperdb, date, password
8382

84-
import rfc2822
83+
from roundup import hyperdb, date, password, rfc2822
8584

8685
SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '')
8786

@@ -1026,6 +1025,7 @@ def uidFromAddress(db, address, create=1, **user_props):
10261025
if create:
10271026
return db.user.create(username=address, address=address,
10281027
realname=realname, roles=db.config.NEW_EMAIL_USER_ROLES,
1028+
password=password.Password(password.generatePassword()),
10291029
**user_props)
10301030
else:
10311031
return 0

roundup/password.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: password.py,v 1.8 2002-12-18 23:57:09 richard Exp $
18+
# $Id: password.py,v 1.9 2003-04-10 05:12:41 richard Exp $
1919

2020
__doc__ = """
2121
Password handling (encoding, decoding).
2222
"""
2323

24-
import sha, re, string
24+
import sha, re, string, random
2525
try:
2626
import crypt
2727
except:
@@ -48,6 +48,10 @@ def encodePassword(plaintext, scheme, other=None):
4848
raise ValueError, 'Unknown encryption scheme "%s"'%scheme
4949
return s
5050

51+
def generatePassword(length=8):
52+
chars = string.letters+string.digits
53+
return ''.join([random.choice(chars) for x in range(length)])
54+
5155
class Password:
5256
'''The class encapsulates a Password property type value in the database.
5357

roundup/templates/classic/dbinit.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: dbinit.py,v 1.33 2003-01-27 16:40:37 kedder Exp $
18+
# $Id: dbinit.py,v 1.34 2003-04-10 05:12:42 richard Exp $
1919

2020
import os
2121

@@ -96,20 +96,23 @@ def open(name=None):
9696
#
9797
# SECURITY SETTINGS
9898
#
99-
# new permissions for this schema
99+
# See the configuration and customisation document for information
100+
# about security setup.
101+
# Add new Permissions for this schema
100102
for cl in 'issue', 'file', 'msg', 'user', 'query', 'keyword':
101103
db.security.addPermission(name="Edit", klass=cl,
102104
description="User is allowed to edit "+cl)
103105
db.security.addPermission(name="View", klass=cl,
104106
description="User is allowed to access "+cl)
105107

106-
# Assign the access and edit permissions for issue, file and message
108+
# Assign the access and edit Permissions for issue, file and message
107109
# to regular users now
108110
for cl in 'issue', 'file', 'msg', 'query', 'keyword':
109111
p = db.security.getPermission('View', cl)
110112
db.security.addPermissionToRole('User', p)
111113
p = db.security.getPermission('Edit', cl)
112114
db.security.addPermissionToRole('User', p)
115+
113116
# and give the regular users access to the web and email interface
114117
p = db.security.getPermission('Web Access')
115118
db.security.addPermissionToRole('User', p)

roundup/templates/classic/html/style.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ a[href]:hover { color:blue; text-decoration: underline; }
77
a[href]:link { color:blue; text-decoration: none; }
88
a[href] { color:blue; text-decoration: none; }
99

10-
a.classhelp:hover { font-weight: bold; }
11-
a.classhelp:link { font-weight: bold; }
12-
a.classhelp { font-weight: bold; }
13-
1410
table.body {
1511
border: 0;
1612
padding: 0;

0 commit comments

Comments
 (0)