added on local at 2026-07-01 21:47:31
| 1 | #!/usr/bin/perl | |
| 2 | #====================================================================== | |
| 3 | # RePricer -- buyer logout. | |
| 4 | # | |
| 5 | # Revokes the buyer's session row and clears the cookie. Always 302s | |
| 6 | # back to the storefront (so a logged-out buyer lands on the public | |
| 7 | # product list, not a 404). | |
| 8 | #====================================================================== | |
| 9 | use strict; | |
| 10 | use warnings; | |
| 11 | ||
| 12 | use lib '/var/www/vhosts/3dshawn.com/repricer.3dshawn.com'; | |
| 13 | use CGI; | |
| 14 | use MODS::DBConnect; | |
| 15 | use MODS::RePricer::Config; | |
| 16 | use MODS::RePricer::BuyerAuth; | |
| 17 | ||
| 18 | my $q = CGI->new; | |
| 19 | my $form = $q->Vars; | |
| 20 | my $db = MODS::DBConnect->new; | |
| 21 | my $cfg = MODS::RePricer::Config->new; | |
| 22 | my $auth = MODS::RePricer::BuyerAuth->new; | |
| 23 | my $DB = $cfg->settings('database_name'); | |
| 24 | ||
| 25 | $| = 1; | |
| 26 | ||
| 27 | my $sid = $form->{id} || $form->{storefront_id} || 0; | |
| 28 | $sid =~ s/[^0-9]//g; | |
| 29 | ||
| 30 | my $dbh = $db->db_connect(); | |
| 31 | my $buyer = $auth->verify($q, $db, $dbh, $DB); | |
| 32 | my $cookie = $auth->logout($db, $dbh, $DB, $buyer ? $buyer->{session_id} : ''); | |
| 33 | $db->db_disconnect($dbh); | |
| 34 | ||
| 35 | my $back = $sid ? "/store.cgi?id=$sid" : '/'; | |
| 36 | print "Status: 302 Found\n"; | |
| 37 | print "Set-Cookie: $cookie\n"; | |
| 38 | print "Location: $back\n\n"; |