Hello,
First time post. I am trying to implement the use of CGI::Application::Plugin::Authentication and I receive the following error when executing the script.
Error:
Error executing class callback in init stage: cfg_file: must have at least one config file. at MyApp/User.pm line 23
Below is the code I thought would be relevant.
package MyApp::User;
use strict;
use CGI::Carp qw/fatalsToBrowser/;
use base 'CGI::Application';
use DBI;
use CGI::Application::Plugin::DBH (qw/dbh_config dbh/);
use CGI::Application::Plugin::ConfigAuto (qw/cfg cfg_file/);
use CGI::Application::Plugin::Session;
use CGI::Application::Plugin::Authentication;
# ----------------------------------------------------------------
# CGIapp_int
# ----------------------------------------------------------------
sub cgiapp_init {
my $self = shift;
my $dbh = $self->cfg('dsn'), $self->cfg('user'), $self->cfg('password');
$self->authen->config(
DRIVER => [ 'DBI', # This is line 23 the error message is referring to.
DBH => $dbh,
TABLE => 'user',
CONSTRAINTS => {
'user.name' => '__CREDENTIAL_1__',
'MD5:user.password' => '__CREDENTIAL_2__'
}
],
);
$self->authen->protected_runmodes(qr/^auth_/, 'display_user_form');
}
#------------------------------------------------------------------------------
# Define our run modes
#------------------------------------------------------------------------------
sub setup {
my $self = shift;
$self->start_mode('display_user_form');
$self->error_mode('error');
$self->mode_param('rm');
$self->run_modes(
'display_user_form' => 'display_user_form'
);
}
#------------------------------------------------------------------------------
# Execute the following before we execute the requested run mode
#------------------------------------------------------------------------------
sub cgiapp_prerun {
my $self = shift;
$self->dbh_config($self->cfg('dsn'), $self->cfg('user'), $self->cfg('password'));
$self->tmpl_path($self->cfg('template_path'));
print $self;
}
In the cgi file I am calling the config file like so.
$webapp->cfg_file('myapp.cfg');
The config file looks like so:
$cfg{user} = 'username';
$cfg{password} = 'password';
$cfg{DB_Name} = 'db_name';
$cfg{DB_Server} = 'localhost';
$cfg{dsn} = "DBI:mysql:$cfg{DB_Name}:$cfg{DB_Server}";
$cfg{template_path} = 'templates';
\%cfg
I am lost as to how to correct the error. Thank you for your time.
Kevin
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.