<:#:>Because this isn't set automatically for login pages<:/#:> <:call `CONNECTION.setContentType('text/html')`:> <:#:>Attempt to get form arguments<:/#:> <:args username password:> <:#:>Did we get a submission, or are we just showing the login page?<:/#:> <:if `username and password`:> <:#:>If we got a username/password submission<:/#:> <:#:>Attempt to validate the username/password combo<:/#:> <:import auth:> <:if `not auth.getAuthorizer().login(CONNECTION, username, password)`:> <:#:> What to do if the username/password combo is bogus, or potentially, they actually plan to use username & password as arguments to the page that we interrupted. Probably should just do what you'd normally do (i.e. show the form) and let them know they messed up. It should also make sure to preserve the vals argument (see below) so that if/when the eventually do manage to log in successfully, everything works as it should. <:/#:> <:args vals:> <:if `vals is None`:> <:#:> We actually weren't the ultimate destination for username and password, so package up args and don't say the password was incorrect <:/#:> <:import cPickle:> <:import base64:> <:call `vals=base64.encodestring(cPickle.dumps(CONNECTION.args))`:> <:else:> <:#:> Ok, auth stuff is bogus, yell, and pass through vals <:/#:> Password Incorrect! <:/if:>
Username:
Password:
<:#:>stow any args that were put to us for the original thing<:/#:> <:hidden vals=`vals`:>
<:else:> <:#:> Ok! username/password combo is valid, re-set CONNECTION.args to what it was when we interrupted and showed the login form, then raise the magical OK value (ok, it's just the string "OK") to say "just do whatever you would've done if everything were normal to begin with". <:/#:> <:args vals:> <:if `vals`:> <:import cPickle:> <:import base64:> <:call `CONNECTION.args = cPickle.loads(base64.decodestring('\n'.join(vals.split('
'))))`:> <:/if:> <:raise OK:> <:/if:> <:else:> <:#:>no password submission stuff, so show the login form<:/#:>
Username:
Password:
<:#:>stow any args that were put to us for the original thing<:/#:> <:import cPickle:> <:import base64:> <:hidden vals=`base64.encodestring(cPickle.dumps(CONNECTION.args))`:>
<:/if:>