Adding failed_user_restore hook for bypassing the dead session problem
Jay Kuri [Wed, 4 Feb 2009 21:40:41 +0000 (21:40 +0000)]
lib/Catalyst/Authentication/Realm.pm

index 5f8c1e9..ea5c6dd 100644 (file)
@@ -192,12 +192,21 @@ sub restore_user {
         # this sets the realm the user originated in.
         $user->auth_realm($self->name);
     } else {
-               Catalyst::Exception->throw("Store claimed to have a restorable user, but restoration failed.  Did you change the user's id_field?");
+               $app->log->error("Store claimed to have a restorable user, but restoration failed.  Did you change the user's id_field?");
+               $self->failed_user_restore($c);
        }
         
     return $user;
 }
 
+## this occurs if there is a session but the thing the session refers to
+## can not be found.  Do what you must do here.
+sub failed_user_restore {
+       my ($self, $c) = @_;
+       
+       $self->remove_persisted_user($c);
+}
+
 sub persist_user {
     my ($self, $c, $user) = @_;