}
sub new {
- my ($class, $institution, $login) = @_;
+ my ($class, $institution, $login, $state) = @_;
my $type = ref($class) || $class;
my $self = {};
bless( $self, $type );
return undef unless
- $self->login( $login->{id}, $login->{password} );
+ $self->login( $login->{id}, $login->{password}, $state );
return $self;
}
sub login {
- my( $self, $username, $password ) = @_;
+ my( $self, $username, $password, $state ) = @_;
syslog('LOG_DEBUG', "OILS: Logging in with username $username");
+
+ if ($state and ref $state and $$state{authtoken}) {
+ $self->{authtoken} = $$state{authtoken};
+ return $self->{authtoken} if ($self->fetch_session); # fetch the session
+ }
+
my $nonce = rand($$);
my $seed = $U->simplereq(
'open-ils.auth',
return $key;
}
+sub state {
+ my $self = shift;
+ return { authtoken => $self->{authtoken} };
+}
+
#
# find_patron($barcode);
# find_patron(barcode => $barcode); # same as above