CGI-Application-Plugin-Authentication-Driver-DBIC
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/Authentication/Driver/DBIC.pm view on Meta::CPAN
FIELD_METHODS => [qw(userid domain password)]
FIELD_METHODS supports filters as specified by
L<CGI::Application::Plugin::Authentication::Driver>
=back
=head1 METHODS
=head2 verify_credentials
This method will test the provided credentials against the values found in
the database, according to the Driver configuration.
=cut
sub verify_credentials {
my $self = shift;
my @creds = @_;
my @_options = $self->options;
die "The Class::DBIx driver requires a hash of options" if @_options % 2;
my %options = @_options;
my $schema = $options{SCHEMA};
die "SCHEMA option must be set."
unless($schema);
die "SCHEMA must be a DBIx::Class::Schema."
unless($schema->isa('DBIx::Class::Schema'));
my $class = $options{CLASS};
die "CLASS option must be set." unless($class);
return unless(scalar(@creds) eq scalar(@{$options{FIELD_METHODS}}));
my @crednames=@{$self->authen->credentials};
my %search;
my %compare;
my $i=0;
# There's a lot of remapping lists/arrays into hashes here
# Most of this is due to needing a hash to perform a search,
# and another hash to perform comparisions if the search is
# encrypted. Also verify that columns that exist have been specified.
for(@{$options{FIELD_METHODS}}) {
t/authenticate.t view on Meta::CPAN
$ENV{CGI_APP_RETURN_ONLY} = 1;
# Missing Credentials
my $query =
CGI->new( { auth_username => 'user1', rm => 'two' } );
my $cgiapp = TestAppAuthenticate->new( QUERY => $query );
my $results = $cgiapp->run;
ok(!$cgiapp->authen->is_authenticated,'missing credentials - login failure');
is( $cgiapp->authen->username, undef, 'missing credentials - username not set' );
# Successful Login
$query =
CGI->new( { auth_username => 'user1', auth_password => '123', rm => 'two' } );
$cgiapp = TestAppAuthenticate->new( QUERY => $query );
$results = $cgiapp->run;
ok($cgiapp->authen->is_authenticated,'successful login');
is( $cgiapp->authen->username, 'user1', 'successful login - username set' );
( run in 0.301 second using v1.01-cache-2.11-cpan-4d50c553e7e )