[Catalyst-commits] r12497 - Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial

xenoterracide at dev.catalyst.perl.org xenoterracide at dev.catalyst.perl.org
Thu Dec 31 13:14:40 GMT 2009


Author: xenoterracide
Date: 2009-12-31 13:14:40 +0000 (Thu, 31 Dec 2009)
New Revision: 12497

Modified:
   Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod
Log:
fix missing username/password in Login controller

|| "" is reduntant if no credential is found it will already be empty.
defined()  will always return true check to see if variables are empty instead.
add an else and appropriate error message in the event all credentials weren't
submitted.

Modified: Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod
===================================================================
--- Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod	2009-12-30 16:54:51 UTC (rev 12496)
+++ Catalyst-Manual/5.80/trunk/lib/Catalyst/Manual/Tutorial/05_Authentication.pod	2009-12-31 13:14:40 UTC (rev 12497)
@@ -388,11 +388,11 @@
         my ($self, $c) = @_;
     
         # Get the username and password from form
-        my $username = $c->request->params->{username} || "";
-        my $password = $c->request->params->{password} || "";
+        my $username = $c->request->params->{username};
+        my $password = $c->request->params->{password};
     
         # If the username and password values were found in form
-        if (defined($username) && defined($password)) {
+        if ($username && $password) {
             # Attempt to log the user in
             if ($c->authenticate({ username => $username,
                                    password => $password  } )) {
@@ -404,6 +404,9 @@
                 # Set an error message
                 $c->stash->{error_msg} = "Bad username or password.";
             }
+        } else {
+            # Set an error message
+            $c->stash->{error_msg} = "Empty username or password.";
         }
     
         # If either of above don't work out, send to the login page




More information about the Catalyst-commits mailing list