[cgiapp] Saving Data From Authentication Phase

adam at spatialsystems.org adam at spatialsystems.org
Mon Jan 7 21:47:28 EST 2008


I sent this 4 hours ago but didn't see it come back to me.  Did this not get sent out by the mail server?
 
I'm using CGI::Application::Plugin::Session and CGI::Application::Plugin::Authentication.  With CGI::Application::Plugin::Authentication I'm using the Generic driver.

I have an authentication object in my anonymous subroutine ref that I use for authentication with the Generic driver.  The authentication object returns 0 or 1 if the username/password is valid or not.  And I can also ask for the users info after the user is logged in and it returns a hashref.

How can I save this hashref ( $users_hash_ref = $ad_auth->getUserInfo ) of user info and keep it in my Session for all requests where the user is logged in?

Here is some of my code:

sub setup {

  #  setup authentication
  $self->authen->config(
      DRIVER => [ 'Generic', \&my_login ],
      STORE => 'Session',
      LOGIN_RUNMODE => 'login',
      POST_LOGIN_RUNMODE => 'main',
      LOGOUT_RUNMODE => 'login',
  );

}

sub my_login {

  my ($username, $password) = @_;

  #  connect to auth network
  my $ad_auth = MyCompany::ActiveDirectory->new('WINDOWS');

  return 0 if not $ad_auth->login( $username, $password );

  #  how do I store this info in the hash ref so I always have it???
  $users_hash_ref = $ad_auth->getUserInfo;

  retrun 1;

}


Thanks,
Adam



More information about the cgiapp mailing list