diff options
author | Robert Haas | 2009-05-22 19:23:33 +0000 |
---|---|---|
committer | Robert Haas | 2009-05-22 19:23:33 +0000 |
commit | a60a6817d968c50d06958d4010cee84afbb58502 (patch) | |
tree | a3f38fd5c60722e786e732ce798b894deeda8630 /perl-lib | |
parent | 5bc9ab5aee7ff20941e0ea6a42aa9c80e5f8f946 (diff) |
Log in/log out links.
In passing, fix a wrong identifier in PgCommitFest::DB::delete, fix session
cookie path in PgCommitFest::Handler::login and remove an unnecessary trace
setting, and rip out some superfluous CSS code.
Diffstat (limited to 'perl-lib')
-rw-r--r-- | perl-lib/PgCommitFest/DB.pm | 4 | ||||
-rw-r--r-- | perl-lib/PgCommitFest/Handler.pm | 14 | ||||
-rw-r--r-- | perl-lib/PgCommitFest/Request.pm | 1 |
3 files changed, 15 insertions, 4 deletions
diff --git a/perl-lib/PgCommitFest/DB.pm b/perl-lib/PgCommitFest/DB.pm index c0d4e49..0cd3b7d 100644 --- a/perl-lib/PgCommitFest/DB.pm +++ b/perl-lib/PgCommitFest/DB.pm @@ -26,11 +26,11 @@ sub delete { while (my ($k, $v) = each %$criteria) { if (ref $v) { push @where, - $self->{'dbh'}->quote_identifier($table) . ' = ' . $$v; + $self->{'dbh'}->quote_identifier($k) . ' = ' . $$v; } else { push @where, - $self->{'dbh'}->quote_identifier($table) . ' = ?'; + $self->{'dbh'}->quote_identifier($k) . ' = ?'; push @bind, $v; } } diff --git a/perl-lib/PgCommitFest/Handler.pm b/perl-lib/PgCommitFest/Handler.pm index 72b0c4f..b2a32ad 100644 --- a/perl-lib/PgCommitFest/Handler.pm +++ b/perl-lib/PgCommitFest/Handler.pm @@ -109,11 +109,10 @@ EOM sysread(RANDOM_BITS, $random_bits, 16); close(RANDOM_BITS); my $session_cookie = unpack("H*", $random_bits); - $r->db->{'trace'} = 1; $r->db->insert('session', { 'id' => $session_cookie, 'username' => $u->{'username'} }); $r->db->commit; - $r->header('Set-Cookie', "session=$session_cookie"); + $r->header('Set-Cookie', "session=$session_cookie; path=/"); $r->redirect($value{'uri'} ne '' ? $value{'uri'} : '/'); } else { @@ -125,4 +124,15 @@ EOM $r->render_template('login'); } +sub logout { + my ($r) = @_; + $r->header('Set-Cookie', "session=; path=/"); + my $session = $r->cookie('session'); + if (defined $r->cookie('session')) { + $r->db->delete('session', { 'id' => $r->cookie('session') }); + $r->db->commit(); + } + $r->redirect('/'); +} + 1; diff --git a/perl-lib/PgCommitFest/Request.pm b/perl-lib/PgCommitFest/Request.pm index 7f99b2e..7e3e878 100644 --- a/perl-lib/PgCommitFest/Request.pm +++ b/perl-lib/PgCommitFest/Request.pm @@ -170,6 +170,7 @@ sub render_template { %stash = %$vars if defined $vars; $stash{'control'} = $self->{'control'}; $template->process('header.tt2', { + 'authenticate' => $self->authenticate(), 'link' => $self->{'link'}, 'title' => $self->{'title'}, 'error_list' => $self->{'error_list'}, |