Make error more useful
Tomas Doran [Fri, 12 Jun 2009 10:27:58 +0000 (10:27 +0000)]
Changes
lib/Catalyst/Plugin/Authentication.pm

diff --git a/Changes b/Changes
index 862aa63..ee72c9e 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension Catalyst::Plugin::Authentication
 
+      - Die with a useful error message if we are about to try to restore
+        a user from a realm which does not exist. (t0m)
+
 0.10012 Sat Jun  6 10:58:43 BST 2009
       - Add Catalyst::Authentication::Credential::Remote which authenticates you
         directly from environment variables passed by your web server. This
index 30cdaa3..bde7cc4 100644 (file)
@@ -165,10 +165,10 @@ sub find_realm_for_persisted_user {
     } else {
         ## we have no choice but to ask each realm whether it has a persisted user.
         foreach my $realmname (@{$c->_auth_realm_restore_order}) {
-            my $ret = $c->auth_realms->{$realmname}->user_is_restorable($c);
-            if ($ret) {
-                return $c->auth_realms->{$realmname};
-            }
+            my $realm = $c->auth_realms->{$realmname}
+                || Catalyst::Exception->throw("Could not find authentication realm '$realmname'");
+            return $realm
+                if $realm->user_is_restorable($c);
         }
     }
     return undef;