[Yapcom checkin] rev 46 - / lib/YAPC t templates

[prev] [thread] [next] [lurker] [Date index for 2003/11/25]

From: svn
Subject: [Yapcom checkin] rev 46 - / lib/YAPC t templates
Date: 16:12 on 25 Nov 2003
Author: gabor
Date: 2003-11-25 16:12:40 +0200 (Tue, 25 Nov 2003)
New Revision: 46

Modified:
   META.yml
   README
   lib/YAPC/Organizer.pm
   t/03-web-adduser.t
   templates/lost_password.tmpl
Log:
accessing lost_password without any information crashed the site

Modified: META.yml
===================================================================
--- META.yml	2003-11-25 11:28:12 UTC (rev 45)
+++ META.yml	2003-11-25 14:12:40 UTC (rev 46)
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         Yapcom
-version:      0.07_02
+version:      0.08
 version_from: lib/YAPC/Organizer.pm
 installdirs:  site
 requires:

Modified: README
===================================================================
--- README	2003-11-25 11:28:12 UTC (rev 45)
+++ README	2003-11-25 14:12:40 UTC (rev 46)
@@ -39,7 +39,11 @@
 
 CHANGES
 ---------
-0.07_03 2003.11.
+0.08_01  2003.11.
+    -
+
+
+0.08  2003.11.25
     - refactoring: using Class::DBI more in the way it should be used
     - refactoring: moving run_mode dispatching, cleaning up the run_modes and authentication 
     - eliminate the 'run' field and base all the actions (run_mode) on the name of the file.

Modified: lib/YAPC/Organizer.pm
===================================================================
--- lib/YAPC/Organizer.pm	2003-11-25 11:28:12 UTC (rev 45)
+++ lib/YAPC/Organizer.pm	2003-11-25 14:12:40 UTC (rev 46)
@@ -192,14 +192,24 @@
     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');
-        $t->param(MESSAGE => 'No such e-mail');
-        return $t->output;
-    } 
-     
-    my $t = $self->_server_page('email_sent');
+    my $t = $self->_server_page('lost_password');
+
+    my $person;
+    if ($q->param('submit')) {
+       eval {
+          ($person) = YAPC::Person->search(email =>  $q->param('email'));
+       };
+       if ($@ or not $person) {
+           $t->param(MESSAGE => 'No such e-mail');
+           return $t->output;
+       } else {
+       }
+    } else {
+       return $t->output;
+    }
+
+    # OK
+    $t = $self->_server_page('email_sent');
     $self->send_email_with_password($person);
     $t->param(SENT_PASSWORD => 1);
     return $t->output;

Modified: t/03-web-adduser.t
===================================================================
--- t/03-web-adduser.t	2003-11-25 11:28:12 UTC (rev 45)
+++ t/03-web-adduser.t	2003-11-25 14:12:40 UTC (rev 46)
@@ -440,11 +440,21 @@
    like($result, qr/Validation code was sent/, 'Validation code was sent');
 }
 
+####### access lost_password page with no data
+{
+   local $ENV{REQUEST_URI}   = '/lost_password.html';
+   my $q = CGI->new();
+   my $webapp = YAPC::Organizer->new;
+   $webapp->query($q);
+   my $result = $webapp->run();
+   like($result, qr@<h2>Send lost password</h2>@, 'lost_password page accessed');
+}
 
+
 ####### get lost password
 {
    local $ENV{REQUEST_URI}   = '/lost_password.html';
-   my $q = CGI->new({email => 'bad-email'});
+   my $q = CGI->new({email => 'bad-email', submit =>1});
    my $webapp = YAPC::Organizer->new;
    $webapp->query($q);
    my $result = $webapp->run();
@@ -455,7 +465,7 @@
 ## password sent (we should check the real e-mail somehow)
 {
    local $ENV{REQUEST_URI}   = '/lost_password.html';
-   my $q = CGI->new({email => $people[0]{email}});
+   my $q = CGI->new({email => $people[0]{email}, submit => 1});
    my $webapp = YAPC::Organizer->new;
    $webapp->query($q);
    my $result = $webapp->run();

Modified: templates/lost_password.tmpl
===================================================================
--- templates/lost_password.tmpl	2003-11-25 11:28:12 UTC (rev 45)
+++ templates/lost_password.tmpl	2003-11-25 14:12:40 UTC (rev 46)
@@ -1,4 +1,4 @@
-<TMPL_VALUE NAME="title" VALUE="Login">
+<TMPL_VALUE NAME="title" VALUE="Send lost password">
 <TMPL_INCLUDE NAME="header.tmpl">
      <td valign="top">
 <p>
@@ -8,7 +8,7 @@
 <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>
+<tr><td></td><td><input type="submit" name="submit" value="Send password"></td></tr>
 </table>
 </form>
 

Generated at 17:06 on 25 Nov 2003 by mariachi 0.51