# 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;
## 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 {
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" );
}
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';
$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");