chiark / gitweb /
wip
[cgi-auth-flexible.git] / cgi-auth-hybrid.pm
index b7bf76b1e7c5479e6b5486e2fc7609d1c48e4562..953db1518c38a3dd3d97a7af0408178cce19afb7 100644 (file)
@@ -247,6 +247,7 @@ sub _check_core ($) {
     #  -/n y2  POST  nrmu     request from cleared session
     #                           revoke y2
     #                           treat as   -/n n POST
+    #
     #  -/n n   GET   n        cross-site link but user not logged in
     #                           show login form with redirect to orig params
     #
@@ -352,41 +353,21 @@ CGI::Auth::Hybrid - web authentication optionally using cookies
 
 =head1 USAGE PATTERN FOR SIMPLE APPLICATIONS
 
- if ( form submission is login request ) {
-     check login details, if wrong print error and quit
-     $authreq->record_login(...username...);
- }
- if ( form submission is logout request ) {
-     my $logged_out_user = $authreq->logout();
-     if (!defined $logged_out_user) {
-        print "you are not logged in" error and quit
-     } else {
-        print "goodbye $username you are now logged out" and quit
-     }
- }
- if ( !$authreq->check() ) {
-     display login form, quit
+ $authreq->check_ok() or return;
 
+ blah blah blah
+ $authreq->mutating();
+ blah blah blah
 
 =head1 USAGE PATTERN FOR FANCY APPLICATIONS
 
- if ( form submission is login request ) {
-     check login details, if wrong print error and quit
-     $authreq->record_login(...username...);
- }
- if ( !$authreq->check() ) {
-     display login form, quit
- if ( form submission is logout request ) {
-     die unless $authreq->mutate();
-     my $logged_out_user = $authreq->logout();
-     if (!defined $logged_out_user) {
-        print "you are not logged in" error and quit
-     } else {
-        print "goodbye $username you are now logged out" and quit
+ my $divert_kind = $authreq->check_divert();
+ if ($divert_kind) {
+     if ($divert_kind eq 'LOGGEDOUT') {
+        print "goodbye you are now logged out" and quit
+     } elsif ($divert_kind eq 'NOCOOKIES') {
+        print "you need cookies" and quit
+     ... etc.
      }
  }
 
-
-advantages of cookie
- - user can sort of log out by clearing cookies
- - sophisticated applications can have get-requests