<%once>
use CGI::Auth::Flexible;
-my $verifier = CGI::Auth::Flexible->new_verifier(
- dir => "/home/ian/things/Nj-awaymsg/nj-awaymsg.git/data",
- CGI::Auth::Flexible->mason_params();
- );
-my $authreq = $verifier->new_mason_request(\%ARGS);
-</%perl>
+
+sub do_redirect_mason ($$$$) {
+ my ($c, $ar, $new_url, $cookie) = @_;
+ $m->auto_send_headers(0);
+ CGI::Auth::Flexible::do_redirect_cgi($c,$ar,$new_url,$cookie);
+}
+
+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>
+<%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>
+% }