=head1 SYNOPSIS
-You should be creating these objects through L<Catalyst::Authentication::Store::LDAP::Backend>'s "get_user" method, or just letting $c->login do
+You should be creating these objects through L<Catalyst::Authentication::Store::LDAP::Backend>'s "get_user" method, or just letting $c->authenticate do
it for you.
sub action : Local {
my ( $self, $c ) = @_;
- $c->login($c->req->param(username), $c->req->param(password));
+ $c->authenticate({
+ id => $c->req->param(username),
+ password => $c->req->param(password)
+ );
$c->log->debug($c->user->username . "is really neat!");
}
use strict;
use warnings;
-our $VERSION = '0.1001';
+our $VERSION = '0.1004';
-BEGIN { __PACKAGE__->mk_accessors(qw/user store/) }
+BEGIN { __PACKAGE__->mk_accessors(qw/user store _ldap_connection/) }
use overload '""' => sub { shift->stringify }, fallback => 1;
= $self->store->ldap_bind( undef, $self->ldap_entry->dn, $password,
'forauth' );
if ( defined($ldap) ) {
+ if ($self->store->role_search_as_user) {
+ # FIXME - This can be removed and made to use the code below..
+ # Have to do the role lookup _now_, as this is the only time
+ # that we have the user's password/ldap bind..
+ $self->roles($ldap);
+ }
+ # Stash a closure which can be used to retrieve the connection in the users context later.
+ $self->_ldap_connection( sub {
+ $self->store->ldap_bind( undef, $self->ldap_entry->dn, $password )
+ });
return 1;
}
else {
sub roles {
my $self = shift;
- return $self->store->lookup_roles($self);
+ my $ldap = shift;
+ $self->{_roles} ||= [$self->store->lookup_roles($self, $ldap)];
+ return @{$self->{_roles}};
}
=head2 for_session