|
Robert Thomas Davis
rdavisunr at yahoo.com
Wed Jan 19 13:20:25 EST 2005
Hey all
My site requires a password to be accessed...I do not
really care what the user name is. Thus, I would like
to populate the login prompt with a default name, like
user or admin, etc. Is this possible or is it
possible to just prompt for a password and nothing
else? I have included the code I am using (this code
was clipped from an earlier post and modified).
Thanks
Rob
def __auth__(req, user, passwd):
# removed check for user=USER
if passwd == PASS:
# user has successfully authenticated
sess = Session(req)
if sess.has_key('max_inactive'):
# this is an existing session
# check length of inactivity
elapsed = time.time() -
sess['last']
# reset timer for next request
sess['last'] = time.time()
sess.save()
# compare elapsed inactivity to
maximum allowed
if elapsed >
sess['max_inactive']:
# it's been too long
# uncomment to delete
session (optional)
sess.delete()
# force user to
reauthenticate
return 0
else:
# still within time limit
#
req.write("Authorized.\n\n")
# allow user to continue
return 1
else:
# this must be a new session, so
set session variables
# set maximum inactivity allowed,
in seconds
sess['max_inactive'] = 500
# initialize timer
sess['last'] = time.time()
sess.save()
# do new session stuff here
# req.write("Session
started.\n\n")
# allow user to continue
return 1
else:
# wrong user or password, force user to
reauthenticate
return 0
|