[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] CAP::Authentication::Driver:DBI ?


Hi List,

I've been experimenting with CGI::Application::Authentication for a project. I've established a simple test site and successfully Authenticated using first the Dummy, then Generic drivers. I'm having a problem with the DBI driver and wonder whether I've missed something in the docs. Here's the code that fails.

package MyApp;
use DBI;
use base 'CGI::Application';
use CGI::Application::Plugin::Session;
use CGI::Application::Plugin::DBH (qw/dbh_config dbh/);
use CGI::Application::Plugin::Authentication;

__PACKAGE__->authen->config(
#	DRIVER => [ 'DBI',
#				DBH			=> $self->dbh,
#				TABLE		=> 'user_info',
#				CONSTRAINTS	=> {
#					'user_info.user_name' 	=> '__CREDENTIAL_1__',
#					'user_info.user_passwd'	=> '__CREDENTIAL_2__',
#					} ],
	DRIVER => [ 'Generic', { foo_user => 'foo', bar_user => 'bar' } ],
	STORE  => 'Session',
	POST_LOGIN_RUNMODE => 'welcome',
);

__PACKAGE__->authen->protected_runmodes('welcome');

sub cgiapp_init {
	my $self = shift;
	$self->start_mode('welcome');
	$self->run_modes( [ qw/
		welcome
		/ ] );
$self->dbh_config( $ENV{DB_DSN}, $ENV{DB_USER}, $ENV{DB_PWD}, { RaiseError => 1 } );
}

sub welcome {
	my $self = shift;
	
	my $username = $self->authen->username;
	
	my $output = $self->dump_html();
	return $output;
}

1;

Apache error log indicates:
Can't call method "dbh" on an undefined value at /usr/local/www/sites/ ph/modules/MyApp.pm line 31. Compilation failed in require at /usr/local/www/sites/ph/modules/ myapp line 8. BEGIN failed--compilation aborted at /usr/local/www/sites/ph/modules/ myapp line 8.

I'm following the example in the CGI::Application::Plugin::DBH documentation, but I'm not able to get a database handle. The Environment variables are set correctly and are passed to the module. I can store sessions in mysql using the same credentials set up in another trial.

Any ideas or observations?

Ed Pigg


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.