X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAuthentication%2FRealm.pm;h=eb57f60ab365a96586ad50af333cfdbbd62cd00e;hb=9c5d00f9338f85370a24e4ae5a65641975166b2e;hp=019189e1b0ec5f81893a2f184fc64d3b70622c3f;hpb=bf4d93a4eb7914bd8dda9e0c98895353e6653476;p=catagits%2FCatalyst-Plugin-Authentication.git diff --git a/lib/Catalyst/Authentication/Realm.pm b/lib/Catalyst/Authentication/Realm.pm index 019189e..eb57f60 100644 --- a/lib/Catalyst/Authentication/Realm.pm +++ b/lib/Catalyst/Authentication/Realm.pm @@ -71,12 +71,18 @@ sub new { }; if ($@) { + # If the file is missing, then try the old-style fallback, + # but re-throw anything else for the user to deal with. + die unless $@ =~ /^Can't locate/; $app->log->warn( qq(Credential class "$credentialclass" not found, trying deprecated ::Plugin:: style naming. ) ); my $origcredentialclass = $credentialclass; $credentialclass =~ s/Catalyst::Authentication/Catalyst::Plugin::Authentication/; eval { Catalyst::Utils::ensure_class_loaded( $credentialclass ); }; if ($@) { + # Likewise this croak is useful if the second exception is also "not found", + # but would be confusing if it's anything else. + die unless $@ =~ /^Can't locate/; Carp::croak "Unable to load credential class, " . $origcredentialclass . " OR " . $credentialclass . " in realm " . $self->name; } @@ -87,11 +93,17 @@ sub new { }; if ($@) { + # If the file is missing, then try the old-style fallback, + # but re-throw anything else for the user to deal with. + die unless $@ =~ /^Can't locate/; $app->log->warn( qq(Store class "$storeclass" not found, trying deprecated ::Plugin:: style naming. ) ); my $origstoreclass = $storeclass; $storeclass =~ s/Catalyst::Authentication/Catalyst::Plugin::Authentication/; eval { Catalyst::Utils::ensure_class_loaded( $storeclass ); }; if ($@) { + # Likewise this croak is useful if the second exception is also "not found", + # but would be confusing if it's anything else. + die unless $@ =~ /^Can't locate/; Carp::croak "Unable to load store class, " . $origstoreclass . " OR " . $storeclass . " in realm " . $self->name; } @@ -180,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?"); + $c->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) = @_;