Parent Directory
|
Revision Log
- ContentGenerator.pm is now officially the superclass to all modules called by the dispatcher to generate content. - Authen.pm now has a single point of exit, which makes it easier to read, debug, and modify - Login.pm is now a subclass of ContentGenerator, and apart from the HTML, is in it's final form. - All code has been commented up - The authentication wrapper is now a working demonstration. Anyone could stick it on a webserver and try it out. The database code isn't written, so it authenticates against hardcoded strings (username: dennis, passwd: helloworld), but this at least proves that the system is workable. --Dennis
1 #TODO: The HTML code here has two failings: 2 # - It is hard-coded into the script, which is against policy 3 # - It is very ugly and hastily written 4 5 # Other than that, this file is done for the forseeable future, 6 # and should serve us nicely unless the interface to WeBWorK::Authen 7 # changes. 8 9 package WeBWorK::Login; 10 11 use WeBWorK::ContentGenerator; 12 13 our @ISA = qw(WeBWorK::ContentGenerator); 14 15 sub go($) { 16 my $self = shift; 17 my $r = $self->{r}; 18 my $course_env = $self->{courseEnvironment}; 19 # get some stuff together 20 my $user = $r->param("user"); 21 my $key = $r->param("key"); 22 my $passwd = $r->param("passwd"); 23 my $course = $course_env->{"courseName"}; 24 25 26 $r->content_type("text/html"); 27 $r->send_http_header; 28 print '<html><head><title>WeBWorK Login Page</title></head><body>', 29 '<h1>WeBWorK Login Page</h1>'; 30 31 # WeBWorK::Authen::verify will set the note "authen_error" 32 # if invalid authentication is found. If this is done, it's a signal to 33 # us to yell at the user for doing that, since Authen isn't a content- 34 # generating module. 35 if ($r->notes("authen_error")) { 36 print '<font color="red"><b>',$r->notes("authen_error"),"</b></font><br>"; 37 } 38 39 # $self->print_form_data(""," = ","<br>\n"); 40 41 print "Please enter your username and password for <b>", 42 $course, 43 "</b> below: <p>", 44 '<form method="POST" action="',$r->uri,'">'; 45 46 # write out the form data posted to the requested URI 47 $self->print_form_data('<input type="hidden" name="','" value="',"\">\n",qr/^(user|passwd|key)$/); 48 49 print '<table border="0"><tr><td>Username:</td><td><input type="textfield" name="user" value="',$user,'"><br></td></tr>', 50 '<tr><td>Password:</td><td><input type="password" name="passwd" value="',$passwd,'"><i>(Will not be echoed)</i></tr></table>', 51 '<input type="submit" value="Continue">', 52 '</form></body></html>'; 53 54 return OK; 55 } 56 57 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |