From: Tomas Doran Date: Thu, 5 Feb 2009 22:05:32 +0000 (+0000) Subject: Actually error in the appropriate way X-Git-Tag: v0.100092_01~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eea5667a529e81fe21f1c36ee887b0e7d5e29693;p=catagits%2FCatalyst-Plugin-Authentication.git Actually error in the appropriate way --- diff --git a/lib/Catalyst/Authentication/Realm.pm b/lib/Catalyst/Authentication/Realm.pm index d7d33e6..b36d14d 100644 --- a/lib/Catalyst/Authentication/Realm.pm +++ b/lib/Catalyst/Authentication/Realm.pm @@ -191,9 +191,10 @@ sub restore_user { # this sets the realm the user originated in. $user->auth_realm($self->name); - } else { - $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); + } + else { + $self->failed_user_restore($c) || + $c->error("Store claimed to have a restorable user, but restoration failed. Did you change the user's id_field?"); } return $user; @@ -201,10 +202,12 @@ sub restore_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. +## Return true if you can fix the situation and find a user, false otherwise sub failed_user_restore { my ($self, $c) = @_; $self->remove_persisted_user($c); + return; } sub persist_user { diff --git a/t/lib/AuthSessionTestApp.pm b/t/lib/AuthSessionTestApp.pm index b6e4a50..ad6b862 100644 --- a/t/lib/AuthSessionTestApp.pm +++ b/t/lib/AuthSessionTestApp.pm @@ -48,7 +48,8 @@ sub yak : Local { my ( $self, $c ) = @_; ok( $c->sessionid, "session ID was restored after user renamed" ); ok( $c->user_exists, "user appears to exist" ); - ok( !$c->user, "try to restore - user was not restored"); + ok( !$c->user, "user was not restored"); + ok(scalar(@{ $c->error }), 'Error recorded'); ok( !$c->user_exists, "user no longer appears to exist" ); } diff --git a/t/live_app_session.t b/t/live_app_session.t index a1c3ae1..8bf83d5 100644 --- a/t/live_app_session.t +++ b/t/live_app_session.t @@ -6,7 +6,7 @@ use Test::More; BEGIN { eval { require Test::WWW::Mechanize::Catalyst; require Catalyst::Plugin::Session; require Catalyst::Plugin::Session::State::Cookie }; plan skip_all => "This test needs Test::WWW::Mechanize::Catalyst, Catalyst::Plugin::Session and Catalyst::Plugin::Session::State::Cookie installed" if $@; - plan tests => 28; + plan tests => 29; } use lib 't/lib'; @@ -16,7 +16,10 @@ my $m = Test::WWW::Mechanize::Catalyst->new; $m->get_ok("http://localhost/moose", "get ok"); $m->get_ok("http://localhost/elk", "get ok"); -$m->get_ok("http://localhost/yak", "get ok"); + +$m->get("http://localhost/yak"); +ok(!$m->success, 'Not ok, user unable to be resotred == nasal demons'); + $m->get_ok("http://localhost/goat", "get ok"); $m->get_ok("http://localhost/fluffy_bunny", "get ok"); $m->get_ok("http://localhost/possum", "get ok");