[Catalyst] user/session/login/authn 2 electric boogaloo

leonard.a.jaffe at jpmchase.com leonard.a.jaffe at jpmchase.com
Wed Aug 2 22:41:29 CEST 2006


So after getting my auto() method fixed up, I still have the undefined 
value error in the session/user stuff that I was getting earlier.

My code and logs below, (with some debug statements in):

Len.




 Root::auto()

  ########
  ## Get the username from siteminder and log that user in.
  ######## 
  unless ($c->user_exists) {
    my $standardid = $c->request->header('standardid') || 
$c->request->param('laj');
    unless ($c->login(uc($standardid))) {
      $c->error("Could not authenticate".  ($standardid ?  ": $standardid" 
: 'UNKNOWN')  );

      ## TODO: should really redirect to some error page.
      return 0;
    }
  }


[ Len's Commentary: again, if I comment out the outer unless() logic, the 
page renders.  Since the template contains logic of the form [% IF 
Catalyst.user_exists %] You are [% Catalyst.user.name %][% END %] some of 
the Authentication.pm methods are being executed twice, but by the time 
the template calls these methods, the user should be in the session, 
waiting to be accessed. 

But the call to Catalyst.user.name, which fires off $c->user, is 
apparently not finding a value in c->_user, [which I have 
confirmed by dumpering its value at the end of Root::auto, and seeing the 
value reported as undef] which makes user() call suth_restore_user() which 
looks at $store_name & $store,  and after receiving and undef $store, 
dereferences it to call from_session(). ]



C::P::Authentication::auth_restore_user:

sub auth_restore_user {
    my ( $c, $frozen_user, $store_name ) = @_;
$c->log->debug("auth_restore_user called");
$c->log->dumper($frozen_user, 'parm_frozen_user');
$c->log->dumper($store_name, 'parm_store_name');

    $frozen_user ||= $c->_user_in_session;
$c->log->dumper($frozen_user, 'frozen_user');
    return unless defined($frozen_user);

    $store_name  ||= $c->session->{__user_store};
$c->log->dumper($store_name, 'store_name');
    return unless $store_name; # FIXME die unless? This is an internal 
inconsistency

    my $store = $c->get_auth_store($store_name);
$c->log->dumper($store, 'store');
    $c->_user( my $user = $store->from_session( $c, $frozen_user ) );

$c->log->dumper($c->_user, '_user now is');
    return $user;

}




More information about the Catalyst mailing list