[Maypole] Problems with user authentication and a little question.

Jean-Francois Im jean-francois.im@myrealbox.com
Mon, 10 May 2004 04:27:59 -0400


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have been trying to build my own version of the iSellIt demo
application featured on perl.com. So far, it mostly works(ie. I can list
items, categories, etc.). However, I cannot seem to be able to make
users work properly.

This is the authentication function, in the driver module(the entire
driver module source code is at
http://phv.lns.kicks-ass.net/css/CStore.pm.txt).

sub authenticate {
~        my ($self, $r) = @_;
~        unless ($r->{table} eq "itemschariot" or $r->{action} eq "achat") {
~                return OK;
~        }

~        $r->get_user;
~        if (!$r->{user}) {
~                $r->template("login");
~        }
~        return OK;
}

If I try to login manually by going to
http://phv.lns.kicks-ass.net/login and entering my login details(user
list : http://phv.lns.kicks-ass.net/user/list), it does not return an
error but I do not get a cookie nor do I get authentified. If I register
a user, it appears that I am logged onto the frontpage but the
authentication does not persists, nor do I get a cookie(which is
probably why the authentication does not persist). Additionally, I
obtain this error message in the Apache log files(two times).

Use of uninitialized value in subroutine entry at
/usr/local/share/perl/5.6.1/Maypole/Authentication/UserSessionCookie.pm
line 175.
Use of uninitialized value in subroutine entry at
/usr/local/share/perl/5.6.1/Maypole/Authentication/UserSessionCookie.pm
line 175.

However, if I try to enforce authentication by changing the authenticate
function to :

sub authenticate {
~        my ($self, $r) = @_;
#       unless ($r->{table} eq "itemschariot" or $r->{action} eq "achat") {
#               return OK;
#       }
~        if($r->{action} eq "login") {
~                return OK;
~        }

~        $r->get_user;
~        if (!$r->{user}) {
~                $r->template("login");
~        }
~        return OK;
}

I get a different error message in the Apache error log file :

Couldn't load user class CStore::User at
/usr/local/share/perl/5.6.1/Maypole/Authentication/UserSessionCookie.pm
line 130.

I tried looking in the flox source code in CVS, reading the
Authentication in Maypole document, searching Google as well as this
mailing list's archives, without results. I'm probably missing something
small but I can't put my finger on it. Any ideas?

Also, I have a little question. From within a template, how would I get
the classmetadata for another table. What I am trying to do is to have a
subview of all products for a particular category(see
http://phv.lns.kicks-ass.net/categorie/view/3). However, how would I
find the names of the columns for the other table(produit).

This is the relevant part of the template :
[% SET columnlist = [ 'name', 'description', 'manufacturier', 'prix' ];
FOR col = columnlist;
~    NEXT IF col == "id";
~    "<TH>";
~        col;
~    "</TH>";
END %]

Obviously, it leaves the column names from the database, not the pretty
formatted ones. I know that item.produits is a list of all the products
for that particular category, but how would I find the column names from
there?

Thank you in advance,
Jean-Francois Im
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1-nr1 (Windows 2000)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFAnz0M51r72W5ULgYRArI4AJ4zxOWxtBtYV1HgYH0neaQz7qwn6wCeM1gJ
p3l4GvzTllb7MJbRLnn5DzM=
=x+QH
-----END PGP SIGNATURE-----