[prev] [thread] [next] [lurker] [Date index for 2003/11/23]
Author: gabor
Date: 2003-11-23 17:32:15 +0200 (Sun, 23 Nov 2003)
New Revision: 7
Added:
templates/email/password.tmpl
templates/email_sent.tmpl
templates/lost_password.tmpl
templates/lost_validation.tmpl
Modified:
README
lib/YAPC/Organizer.pm
t/03-web-adduser.t
templates/login.tmpl
Log:
add get validation code and get lost password forms
Modified: README
===================================================================
--- README 2003-11-23 14:16:43 UTC (rev 6)
+++ README 2003-11-23 15:32:15 UTC (rev 7)
@@ -34,8 +34,10 @@
CHANGES
---------
-0.07_02 2003.11.16
+0.07_02 2003.11.
- further refactoring the tests
+ - add pages to get back lost password and get validation code again
+ if e-mail was not yet validated.
0.07_01 2003.11.15
@@ -154,11 +156,19 @@
- give error message on validation form if something went wrong
+ - testing the various e-mail sending routines
+
+
+ - test and fix case when non-existing runmode was supplied
+
+ - try to break the system/web interface and then fix it :-)
+
- admin right to some login (probably hard-code to my e-mail address)
- admin can list all the people, indicate who validated and who did not.
show all information for every person
- admin can list all the proposals
+ - write tests that test the real forms with a real web server infront of them.
- allow registrant to be anonymous (not to show in the public interface, but
Modified: lib/YAPC/Organizer.pm
===================================================================
--- lib/YAPC/Organizer.pm 2003-11-23 14:16:43 UTC (rev 6)
+++ lib/YAPC/Organizer.pm 2003-11-23 15:32:15 UTC (rev 7)
@@ -35,6 +35,7 @@
'logout' => 'do_logout',
'send_proposal' => 'do_send_proposal',
'get_validation_code' => 'get_validation_code',
+ 'get_lost_password' => 'get_lost_password',
);
}
@@ -102,17 +103,54 @@
my ($person) = YAPC::Person->search(email => $q->param('email'));
if (not $person) {
- my $t = $self->_server_page('email_sent', "$templates_dir/email_sent.tmpl");
+ my $t = $self->_server_page('lost_validation', "$templates_dir/lost_validation.tmpl");
+ $t->param(MESSAGE => 'No such e-mail');
+ return $t->output;
}
my $t = $self->_server_page('email_sent', "$templates_dir/email_sent.tmpl");
if ($person->authcode ) {
- send_email_with_validation_code($person);
+ $self->send_email_with_validation_code($person);
+ $t->param(SENT_AUTHCODE => 1);
+ } else {
+ $t->param(NOT_SENT_AUTHCODE => 1);
}
+ return $t->output;
+}
-
+sub get_lost_password {
+ my $self = shift;
+ my $q = $self->query;
+
+ my ($person) = YAPC::Person->search(email => $q->param('email'));
+ if (not $person) {
+ my $t = $self->_server_page('lost_password', "$templates_dir/lost_password.tmpl");
+ $t->param(MESSAGE => 'No such e-mail');
+ return $t->output;
+ }
+
+ my $t = $self->_server_page('email_sent', "$templates_dir/email_sent.tmpl");
+ $self->send_email_with_password($person);
+ $t->param(SENT_PASSWORD => 1);
+ return $t->output;
}
+sub send_email_with_password {
+ my $self = shift;
+ my $person = shift;
+ my $q = $self->query;
+ my $mail = HTML::Template->new(
+ filename => "$templates_dir/email/password.tmpl",
+ die_on_bad_params => 0,
+ associate => $q);
+ $mail->param("password" => $person->password);
+ my %mail = (To => $person->email,
+ From => $YAPC::Config::email_address,
+ Subject => "YAPC::Israel::2004 your password",
+ Message => $mail->output,
+ );
+ sendmail(%mail) or die $Mail::Sendmail::error unless $ENV{YAPCOM_NOMAIL};
+}
sub send_email_with_validation_code {
my $self = shift;
@@ -132,13 +170,14 @@
my %mail = (To => $person->email,
From => $YAPC::Config::email_address,
Subject => "YAPC::Israel::2004 registration information",
- Message => $mail->output,
+ Message => $mail->output,
);
sendmail(%mail) or die $Mail::Sendmail::error unless $ENV{YAPCOM_NOMAIL};
+}
-}
+
sub _server_page {
my $self = shift;
my ($page , $filename) = @_;
@@ -271,7 +310,7 @@
return $t->output;
} else {
- send_email_with_validation_code($person);
+ $self->send_email_with_validation_code($person);
# send e-mail to administrator
@@ -370,7 +409,7 @@
=head1 VERSION
-$Id: Organizer.pm,v 1.11 2003/11/16 06:28:40 gabor Exp $
+$Id:$
=head1 AUTHOR
Modified: t/03-web-adduser.t
===================================================================
--- t/03-web-adduser.t 2003-11-23 14:16:43 UTC (rev 6)
+++ t/03-web-adduser.t 2003-11-23 15:32:15 UTC (rev 7)
@@ -24,8 +24,9 @@
my %user1 = %{$people[0]};
-my %user2 = %{$people[1]};
+#YAPC::Test::Data::register_user(1);
+
{
my $q = new CGI;
my $header = $q->header;
@@ -373,6 +374,75 @@
}
+####### get back lost password (user provides e-mail address we send the password)
+####### get validation code if not validated yet
+{
+ my $q = CGI->new({email => 'bad-email', run => 'get_validation_code'});
+ my $webapp = YAPC::Organizer->new;
+ $webapp->query($q);
+ my $result = $webapp->run();
+ like($result, qr/No such e-mail/, 'No such e-mail');
+}
+## already validated
+{
+ my $q = CGI->new({email => $people[0]{email}, run => 'get_validation_code'});
+ my $webapp = YAPC::Organizer->new;
+ $webapp->query($q);
+ my $result = $webapp->run();
+ like($result, qr/already validated/, 'already validated');
+}
+
+
+###### registeriong wihtout validation
+{
+ my %user = %{$people[1]};
+ $user{run} = 'registration';
+ $user{pauseid} = 'MYPAUSEID';
+ my $q = CGI->new(\%user);
+ my $webapp = YAPC::Organizer->new;
+ $webapp->query($q);
+ my $result = $webapp->run();
+ like($result, qr/Thank you for registering/, 'User registered');
+}
+
+
+## validation sent (we should check the real e-mail somehow)
+{
+ my $q = CGI->new({email => $people[1]{email}, run => 'get_validation_code'});
+ my $webapp = YAPC::Organizer->new;
+ $webapp->query($q);
+ my $result = $webapp->run();
+ like($result, qr/Validation code was sent/, 'Validation code was sent');
+}
+
+
+####### get lost password
+{
+ my $q = CGI->new({email => 'bad-email', run => 'get_lost_password'});
+ my $webapp = YAPC::Organizer->new;
+ $webapp->query($q);
+ my $result = $webapp->run();
+ like($result, qr/No such e-mail/, 'No such e-mail');
+}
+
+
+## password sent (we should check the real e-mail somehow)
+{
+ my $q = CGI->new({email => $people[0]{email}, run => 'get_lost_password'});
+ my $webapp = YAPC::Organizer->new;
+ $webapp->query($q);
+ my $result = $webapp->run();
+ like($result, qr/Password was sent/, 'Password was sent');
+}
+
+##### get password of an e-mail which was never validated might need to fail
+##### though this is not a real issue I think.
+
+
+
+
+
+
Added: templates/email/password.tmpl
===================================================================
--- templates/email/password.tmpl 2003-11-23 14:16:43 UTC (rev 6)
+++ templates/email/password.tmpl 2003-11-23 15:32:15 UTC (rev 7)
@@ -0,0 +1,13 @@
+Dear <TMPL_VAR NAME="fname"> <TMPL_VAR NAME="lname">,
+
+Your password is <TMPL_VAR NAME="password">
+
+If you have any questions, don't hesitate to contact us at
+yapc-organizers@xxxx.xxx.xx .
+
+
+regards
+ Gabor Szabo
+ http://www.perl.org.il/YAPC/2004/
+
+
Added: templates/email_sent.tmpl
===================================================================
--- templates/email_sent.tmpl 2003-11-23 14:16:43 UTC (rev 6)
+++ templates/email_sent.tmpl 2003-11-23 15:32:15 UTC (rev 7)
@@ -0,0 +1,28 @@
+<TMPL_VALUE NAME="title" VALUE="Email sending">
+<TMPL_INCLUDE NAME="header.tmpl">
+ <td valign="top">
+<p>
+<TMPL_IF NAME=sent_authcode>
+Validation code was sent
+</TMPL_IF>
+<TMPL_IF NAME=not_sent_authcode>
+This e-mail was already validated.<br>
+<a href=lost_password.html>Get back your lost password</a><br>
+or<br>
+<a href=login.html>Login</a><br>
+</TMPL_IF>
+<TMPL_IF NAME=sent_password>
+Password was sent
+</TMPL_IF>
+
+ <br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br />
+ <hr />
+
+ <p class="bottomtext">
+ Please send comments, questions etc. to
+ <a href="mailto:yapc-organizers@xxxx.xxx.xx">yapc-organizers@xxxx.xxx.xx</a>
+ </p>
+
+ </td>
+<TMPL_INCLUDE NAME="footer.tmpl">
+
Modified: templates/login.tmpl
===================================================================
--- templates/login.tmpl 2003-11-23 14:16:43 UTC (rev 6)
+++ templates/login.tmpl 2003-11-23 15:32:15 UTC (rev 7)
@@ -12,6 +12,9 @@
<tr><td>Password:</td><td><input size=40 name="password" type="password" /></td></tr>
<tr><td></td><td><input type="submit" value="Login"></td></tr>
</table>
+Not yet registered ? <a href=registration.html>Register here</a><br>
+Already registered but <a href=lost_validation.html>lost validation code ?</a><br>
+Already registered but <a href=lost_password.html>lost your password ?</a><br>
</form>
<br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br />
Added: templates/lost_password.tmpl
===================================================================
--- templates/lost_password.tmpl 2003-11-23 14:16:43 UTC (rev 6)
+++ templates/lost_password.tmpl 2003-11-23 15:32:15 UTC (rev 7)
@@ -0,0 +1,26 @@
+<TMPL_VALUE NAME="title" VALUE="Login">
+<TMPL_INCLUDE NAME="header.tmpl">
+ <td valign="top">
+<p>
+<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
+<p>
+<form method="post">
+<input type="hidden" name="run" value="get_lost_password" />
+<input type="hidden" name="next" value="<TMPL_VAR NAME=next>" />
+<table>
+<tr><td>Email:</td><td><input size=40 name="email" value="<TMPL_VAR NAME=email>" /></td></tr>
+<tr><td></td><td><input type="submit" value="Send password"></td></tr>
+</table>
+</form>
+
+ <br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br />
+ <hr />
+
+ <p class="bottomtext">
+ Please send comments, questions etc. to
+ <a href="mailto:yapc-organizers@xxxx.xxx.xx">yapc-organizers@xxxx.xxx.xx</a>
+ </p>
+
+ </td>
+<TMPL_INCLUDE NAME="footer.tmpl">
+
Added: templates/lost_validation.tmpl
===================================================================
--- templates/lost_validation.tmpl 2003-11-23 14:16:43 UTC (rev 6)
+++ templates/lost_validation.tmpl 2003-11-23 15:32:15 UTC (rev 7)
@@ -0,0 +1,28 @@
+<TMPL_VALUE NAME="title" VALUE="Lost validation code">
+<TMPL_INCLUDE NAME="header.tmpl">
+ <td valign="top">
+<p>
+<font color="red"><TMPL_VAR NAME="MESSAGE"></font>
+<p>
+in case you have already registerd but have not validated the
+e-mail address yet, here you can ask the validation code to be sent to you again.
+This will only work if you have not validated yet.
+<form method="post">
+<input type="hidden" name="run" value="get_validation_code" />
+<table>
+<tr><td>Email:</td><td><input size=40 name="email" value="<TMPL_VAR NAME=email>" /></td></tr>
+<tr><td></td><td><input type="submit" value="Get Validation code"></td></tr>
+</table>
+</form>
+
+ <br /> <br /><br /> <br /><br /> <br /><br /> <br /><br /> <br />
+ <hr />
+
+ <p class="bottomtext">
+ Please send comments, questions etc. to
+ <a href="mailto:yapc-organizers@xxxx.xxx.xx">yapc-organizers@xxxx.xxx.xx</a>
+ </p>
+
+ </td>
+<TMPL_INCLUDE NAME="footer.tmpl">
+
Generated at 18:06 on 23 Nov 2003 by mariachi 0.51