chiark / gitweb /
wip login/logout handling
[nj-awaymsg.git] / mason / autohandler
index 469f4820f8691a23470c9e0c3ed5b62930fa4c31..a7d58a44946f99c05d6245f3f1e131392cc5a952 100644 (file)
@@ -7,18 +7,31 @@ sub do_redirect_mason ($$$$) {
     CGI::Auth::Flexible::do_redirect_cgi($c,$ar,$new_url,$cookie);
 }
 
-my $verifier = CGI::Auth::Flexible->new_verifier(
+sub login_ok_self ($$) {
+    my ($c, $ar) = @_;
+    my $password = $c->param('password');
+    return $password eq 'sesame' ? ('self',undef) : (undef,'wrong');
+}
+
+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; },
 #    print => sub { my ($c,$ar,@t) = @_; $m->print(@t); },
     encrypted_only => 0,
+    username_param_names => [],
+    login_ok => \&login_ok_self,
     );
 </%once>
-<%perl>
-my $cgi = $m->cgi_object();
-my $ar = $verifier->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="<% $ENV{'URL'} %>">
+<% $ar->secret_hidden_html() %>
+<input type="submit" name="caf_logout" value="Logout">
+</form>
+% }