fix missing username/password in Login controller
[catagits/Catalyst-Manual.git] / lib / Catalyst / Manual / Tutorial / 05_Authentication.pod
index 2456ca4..ec3a748 100644 (file)
@@ -336,7 +336,6 @@ for the tutorial, but if you wish to use C<myapp.conf>, just convert
 to the following code:
 
     <Plugin::Authentication>
-        use_session 1
         <default>
             password_type clear
             user_model    DB::User
@@ -389,11 +388,11 @@ and update the definition of C<sub index> to match:
         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  } )) {
@@ -405,6 +404,9 @@ and update the definition of C<sub index> to match:
                 # 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
@@ -739,7 +741,7 @@ Then run the following command:
 
     $ DBIC_TRACE=1 perl -Ilib set_hashed_passwords.pl
 
-We had to use the C<-Ilib> arguement to tell perl to look under the 
+We had to use the C<-Ilib> argument to tell perl to look under the 
 C<lib> directory for our C<MyApp::Schema> model.
 
 The DBIC_TRACE output should show that the update worked: