]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/contrib/justlogin.mdwn
(no commit message)
[ikiwiki.git] / doc / plugins / contrib / justlogin.mdwn
1 This plugin is still in development. Currently it does bring up the login page and the login page does, with proper credentials, log in the user, but the returning page errors.
2
3 Place this code into a page:
4
5 <form action="http://portable.local/cgi-bin/ikiwiki.cgi" method="get">
6
7 <input type="hidden" name="do" value="justlogin" />
8
9 <input type="submit" value="Login" /></form>
10
11
12
13 This is the plugin so far:
14
15         #!/usr/bin/perl
16         # Bring up a login page that returns to the calling page
17         package IkiWiki::Plugin::justlogin;
18         
19         use warnings;
20         use strict;
21         use IkiWiki 3.00;
22         
23         sub import {
24                 hook(type => "sessioncgi", id => "justlogin", call => \&sessioncgi);
25                 hook(type => "auth", id => "justlogin", call => \&auth);
26         }
27         
28         sub sessioncgi ($$) {
29                 my $q=shift;
30                 my $session=shift;
31         
32                 debug("jl sessioncgi1 running.");                        
33         
34                 if ($q->param('do') eq 'justlogin') {
35                         debug("Justlogin do=justlogin running.");
36                         if (! defined $session->param("name") ) {
37                                 debug("Justlogin param!defined running.");
38                                 $session->param(postsignin => $ENV{HTTP_REFERER} );
39                                 $session->param("do" => "justgoback" );
40                                 IkiWiki::cgi_savesession($session);
41                                 IkiWiki::cgi_signin($q, $session);
42                                 exit;
43                         } 
44                 } elsif ($session->param('do') eq 'justgoback') {
45                         debug("jl justgoback running.");
46                         if (! defined $session->param("name")) {
47                                 debug("Justlogin redir running.");
48                                 my $page=IkiWiki::possibly_foolish_untaint($q->param('postsignin'));
49                                 $session->clear("postsignin");
50                                 $session->clear("do");
51                                 IkiWiki::cgi_savesession($session);
52                                 IkiWiki::redirect($q, $page);
53                         }
54                 }
55         }
56         
57         sub auth ($$) {                 
58                 # While this hook is not currently used, it needs to exist
59                 # so ikiwiki knows that the wiki supports logins, and will
60                 # enable the Preferences page.
61         }
62                     
63         
64         1
65