Skip to content

Commit 085d354

Browse files
author
Richard Jones
committed
Fixed newuser_action so it sets the cookie with the unencrypted password.
Also made it present nicer error messages (not tracebacks).
1 parent eefa56f commit 085d354

File tree

2 files changed

+42
-19
lines changed

2 files changed

+42
-19
lines changed

roundup-admin

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: roundup-admin,v 1.37 2001-10-23 01:00:18 richard Exp $
19+
# $Id: roundup-admin,v 1.38 2001-11-05 23:45:40 richard Exp $
2020

2121
import sys
2222
if int(sys.version[0]) < 2:
@@ -177,9 +177,9 @@ Command help:
177177
if template not in templates:
178178
print 'Templates:', ', '.join(templates)
179179
while template not in templates:
180-
template = raw_input('Select template [extended]: ').strip()
180+
template = raw_input('Select template [classic]: ').strip()
181181
if not template:
182-
template = 'extended'
182+
template = 'classic'
183183

184184
import roundup.backends
185185
backends = roundup.backends.__all__
@@ -687,6 +687,13 @@ if __name__ == '__main__':
687687

688688
#
689689
# $Log: not supported by cvs2svn $
690+
# Revision 1.37 2001/10/23 01:00:18 richard
691+
# Re-enabled login and registration access after lopping them off via
692+
# disabling access for anonymous users.
693+
# Major re-org of the htmltemplate code, cleaning it up significantly. Fixed
694+
# a couple of bugs while I was there. Probably introduced a couple, but
695+
# things seem to work OK at the moment.
696+
#
690697
# Revision 1.36 2001/10/21 00:45:15 richard
691698
# Added author identification to e-mail messages from roundup.
692699
#

roundup/cgi_client.py

Lines changed: 32 additions & 16 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: cgi_client.py,v 1.49 2001-11-04 03:07:12 richard Exp $
18+
# $Id: cgi_client.py,v 1.50 2001-11-05 23:45:40 richard Exp $
1919

2020
import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes
2121
import binascii, Cookie, time
@@ -571,7 +571,7 @@ def classes(self, message=None):
571571
else:
572572
raise Unauthorised
573573

574-
def login(self, message=None):
574+
def login(self, message=None, newuser_form=None):
575575
self.pagehead('Login to roundup', message)
576576
self.write('''
577577
<table>
@@ -589,30 +589,35 @@ def login(self, message=None):
589589
self.write('</table>')
590590
self.pagefoot()
591591
return
592+
values = {'realname': '', 'organisation': '', 'address': '',
593+
'phone': '', 'username': '', 'password': '', 'confirm': ''}
594+
if newuser_form is not None:
595+
for key in newuser_form.keys():
596+
values[key] = newuser_form[key].value
592597
self.write('''
593598
<p>
594599
<tr><td colspan=2 class="strong-header">New User Registration</td></tr>
595600
<tr><td colspan=2><em>marked items</em> are optional...</td></tr>
596601
<form action="newuser_action" method=POST>
597602
<tr><td align=right><em>Name: </em></td>
598-
<td><input name="realname"></td></tr>
603+
<td><input name="realname" value="%(realname)s"></td></tr>
599604
<tr><td align=right><em>Organisation: </em></td>
600-
<td><input name="organisation"></td></tr>
605+
<td><input name="organisation" value="%(organisation)s"></td></tr>
601606
<tr><td align=right>E-Mail Address: </td>
602-
<td><input name="address"></td></tr>
607+
<td><input name="address" value="%(address)s"></td></tr>
603608
<tr><td align=right><em>Phone: </em></td>
604-
<td><input name="phone"></td></tr>
609+
<td><input name="phone" value="%(phone)s"></td></tr>
605610
<tr><td align=right>Preferred Login name: </td>
606-
<td><input name="username"></td></tr>
611+
<td><input name="username" value="%(username)s"></td></tr>
607612
<tr><td align=right>Password: </td>
608-
<td><input type="password" name="password"></td></tr>
613+
<td><input type="password" name="password" value="%(password)s"></td></tr>
609614
<tr><td align=right>Password Again: </td>
610-
<td><input type="password" name="confirm"></td></tr>
615+
<td><input type="password" name="confirm" value="%(confirm)s"></td></tr>
611616
<tr><td></td>
612617
<td><input type="submit" value="Register"></td></tr>
613618
</form>
614619
</table>
615-
''')
620+
'''%values)
616621
self.pagefoot()
617622

618623
def login_action(self, message=None):
@@ -674,12 +679,15 @@ def newuser_action(self, message=None):
674679
self.db = self.instance.open('admin')
675680

676681
# TODO: pre-check the required fields and username key property
677-
cl = self.db.classes['user']
678-
props, dummy = parsePropsFromForm(self.db, cl, self.form)
679-
uid = cl.create(**props)
680-
self.user = self.db.user.get(uid, 'username')
681-
password = self.db.user.get(uid, 'password')
682-
self.set_cookie(self.user, password)
682+
cl = self.db.user
683+
try:
684+
props, dummy = parsePropsFromForm(self.db, cl, self.form)
685+
uid = cl.create(**props)
686+
except ValueError, message:
687+
return self.login(message, newuser_form=self.form)
688+
self.user = cl.get(uid, 'username')
689+
password = cl.get(uid, 'password')
690+
self.set_cookie(self.user, self.form['password'].value)
683691
return self.index()
684692

685693
def main(self, dre=re.compile(r'([^\d]+)(\d+)'),
@@ -919,6 +927,14 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
919927

920928
#
921929
# $Log: not supported by cvs2svn $
930+
# Revision 1.49 2001/11/04 03:07:12 richard
931+
# Fixed various cookie-related bugs:
932+
# . bug #477685 ] base64.decodestring breaks
933+
# . bug #477837 ] lynx does not like the cookie
934+
# . bug #477892 ] Password edit doesn't fix login cookie
935+
# Also closed a security hole - a logged-in user could edit another user's
936+
# details.
937+
#
922938
# Revision 1.48 2001/11/03 01:30:18 richard
923939
# Oops. uses pagefoot now.
924940
#

0 commit comments

Comments
 (0)