chiark / gitweb /
wip login/logout handling
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Jan 2013 19:33:44 +0000 (19:33 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Jan 2013 19:33:44 +0000 (19:33 +0000)
mason/autohandler
mason/edit
mason/main

index 933ed622e7c260a071f835be9241bea298c627fd..a7d58a44946f99c05d6245f3f1e131392cc5a952 100644 (file)
@@ -13,7 +13,7 @@ sub login_ok_self ($$) {
     return $password eq 'sesame' ? ('self',undef) : (undef,'wrong');
 }
 
-my $ar = CGI::Auth::Flexible->new_verifier(
+our $verifier = CGI::Auth::Flexible->new_verifier(
     dir => "$ENV{'NJAWAYMSG'}/data",
 #    do_redirect => \&do_redirect_mason,
     handle_divert => sub { $m->auto_send_headers(0); return 0; },
@@ -23,18 +23,15 @@ my $ar = CGI::Auth::Flexible->new_verifier(
     login_ok => \&login_ok_self,
     );
 </%once>
-<%perl>
-my $cgi = $m->cgi_object();
-print STDERR ">".$cgi->url()."<\n";
-my $ar = $ar->new_request($cgi);
-if ($ar->check_ok()) {
-   $m->call_next();
-</%perl>
+<%shared>
+our $cgi = $m->cgi_object();
+our $ar = $verifier->new_request($cgi);
+</%shared>
+% if ($ar->check_ok()) {
+%    $m->call_next();
 <hr>
-<form method="POST" action="<% $cgi->url() %>">
+<form method="POST" action="<% $ENV{'URL'} %>">
 <% $ar->secret_hidden_html() %>
 <input type="submit" name="caf_logout" value="Logout">
 </form>
-<%perl>
-}
-</%perl>
+% }
index 96124131d93a83a3e464d4c9c702650882cad3b2..4456d87489ed9be2532e1793beb706a796c17d9d 100755 (executable)
@@ -3,6 +3,9 @@ use AwayMsg;
 db_connect();
 www_begin($r,$m);
 </%init>
+<%shared>
+our ($cgi,$ar);
+</%shared>
 
 <%args>
 $create => undef
@@ -51,6 +54,7 @@ if (!$tx) { die "no such text $textid"; }
 </%perl>
 <& htmlhead, subpage => "Edit \"$tx->{'desc'}\"" &>
 <form action="save" method="post">
+<% $ar->secret_hidden_html() %>
 <&| txtable, tx => $tx, inputs => 1 &>
 <tr><td colspan=2><textarea name="text" cols="79" rows="15"><%
   $tx->{'text'} |h %></textarea></td></tr>
index a9bc72e20621da1a183218ecba490259ef544095..03f25cb8440bb70f47c821bab7d7d6f776bc64da 100755 (executable)
@@ -4,6 +4,9 @@ db_connect();
 www_begin($r,$m);
 my ($sth,$row,$sthi,$rowi);
 </%init>
+<%shared>
+our ($cgi,$ar);
+</%shared>
 <&htmlhead, subpage => 'Overview' &>
 
 <h2>Email addresses and their configuration</h2>
@@ -49,7 +52,8 @@ END
 $sth->execute();
 </%perl>
 % while (my $row= $sth->fetchrow_hashref()) {
-<form action="edit" method="get">
+<form action="<% $ENV{'URL'} %>/edit" method="POST">
+<% $ar->secret_hidden_html() %>
 <h3>Message "<% $row->{'desc'} |h %>"</h3>
 
 <&| txtable, tx => $row &>