I'm trying to get CGI::Session::Auth::DBI to work with PostgreSQL but it's not erroring out or kicking back DB errors. When I put in the wrong dbname it doesn't die.

Here's what I'm trying to do:
1. Get a session authenticated and started.
2. Get DB connection errors kicked back to me.

Can someone see what I'm doing wrong?

Here's my script:
#!/usr/bin/perl -w use strict; use CGI; use CGI::Session; use CGI::Session::Auth::DBI; use CGI::Carp; use DBI; # CGI object for headers, cookies, etc. my $cgi = new CGI; my $session = new CGI::Session(undef, $cgi, {Directory=>'/tmp'}); my $auth = new CGI::Session::Auth({ CGI => $cgi, Session => $session, DSN => 'DBI:PgPP:dbname=databasename', UserTable => 'users', DBUser => 'dbusername', DBPasswd => 'dbpassword', DBAttr => 'PrintError => 1, RaiseError => 1' }); $auth->authenticate(); # check if visitor has already logged in if ($auth->loggedIn) { &showSecretPage; } else { &showLoginPage; } sub showLoginPage { print $cgi->header; print <<EOF; <html> <head> <title>Login</title> </head> <body bgcolor="white" text="black" link="blue" vlink="purple" alink="r +ed"> <form name="form1" method="post" action="./auth.pl"> <p>Password: <input type="text" name="log_username" maxlength="10" + size="10"></p> <p>Username: <input type="text" name="log_password" maxlength="10" + size="10"></p> <p><input type="submit" name="Submit"></p> </form> <p>&nbsp;</p> </body> </html> EOF } sub showSecretPage { print $cgi->header; print "Sucess!"; }
Here's the SQL to create the table in PostgreSQL. The username is "test" with password "pass":
-- -- PostgreSQL database dump -- SET client_encoding = 'LATIN1'; SET check_function_bodies = false; SET client_min_messages = warning; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: users; Type: TABLE; Schema: public; Owner: dbusername; Tables +pace: -- CREATE TABLE users ( userid character varying(50) NOT NULL, first_name character varying(40) NOT NULL, last_name character varying(40) NOT NULL, passwd character varying(16) NOT NULL, email character varying(100) NOT NULL, privilege character varying(2) NOT NULL, username character varying(40) NOT NULL ); ALTER TABLE public.users OWNER TO dbusername; -- -- Name: userid; Type: DEFAULT; Schema: public; Owner: dbusername -- ALTER TABLE users ALTER COLUMN userid SET DEFAULT nextval('"users_user +_ID_seq"'::regclass); -- -- Data for Name: users; Type: TABLE DATA; Schema: public; Owner: dbus +ername -- COPY users (userid, first_name, last_name, passwd, email, privilege, u +sername) FROM stdin; 325684ec1b028eaf562dd484c5607a65 Allan Hubert pass adam@m +ysite.org 0 test \. -- -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: dbuserna +me; Tablespace: -- ALTER TABLE ONLY users ADD CONSTRAINT users_pkey PRIMARY KEY (userid); -- -- PostgreSQL database dump complete --


UPDATE: Found the problem. I was creating the object with CGI::Session::Auth when I should have been using CGI::Session::Auth::DBI

In reply to Trying to get CGI::Session::Auth::DBI to work. by awohld

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.