justint 2011-03-02 03:00:28 +00:00 committed by Joey Hess
parent b156dbdcc2
commit a91bd978d8
1 changed files with 23 additions and 36 deletions

View File

@ -1,4 +1,4 @@
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. 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 goes to prefs. I have no idea why.
Place this code into a page: Place this code into a page:
@ -8,11 +8,8 @@ Place this code into a page:
<input type="submit" value="Login" /></form> <input type="submit" value="Login" /></form>
This is the plugin so far: This is the plugin so far:
#!/usr/bin/perl
#!/usr/bin/perl
# Bring up a login page that returns to the calling page # Bring up a login page that returns to the calling page
package IkiWiki::Plugin::justlogin; package IkiWiki::Plugin::justlogin;
@ -21,45 +18,35 @@ This is the plugin so far:
use IkiWiki 3.00; use IkiWiki 3.00;
sub import { sub import {
hook(type => "sessioncgi", id => "justlogin", call => \&sessioncgi); hook(type => "sessioncgi", id => "justlogin", call => \&sessioncgi);
hook(type => "auth", id => "justlogin", call => \&auth);
} }
sub sessioncgi ($$) { sub sessioncgi ($$) {
my $q=shift; my $q=shift;
my $session=shift; my $session=shift;
debug("jl sessioncgi1 running."); debug("jl sessioncgi1 running.");
if ($q->param('do') eq 'justlogin') { if ($q->param("do") eq "justlogin") {
debug("Justlogin do=justlogin running."); debug("jl do=justlogin running.");
if (! defined $session->param("name") ) { if (! defined $session->param("name") ) {
debug("Justlogin param!defined running."); debug("jl param!defined running.");
$session->param(postsignin => $ENV{HTTP_REFERER} ); $session->param("postsignin" => $ENV{HTTP_REFERER} );
$session->param("do" => "justgoback" ); $session->param("do" => "justgoback" );
IkiWiki::cgi_savesession($session); IkiWiki::cgi_signin($q, $session);
IkiWiki::cgi_signin($q, $session); IkiWiki::cgi_savesession($session);
exit; }
} exit;
} elsif ($session->param('do') eq 'justgoback') { } elsif ($session->param("do") eq "justgoback") {
debug("jl justgoback running."); debug("jl justgoback running.");
if (! defined $session->param("name")) { my $page=$q->param("postsignin");
debug("Justlogin redir running."); $session->clear("postsignin");
my $page=IkiWiki::possibly_foolish_untaint($q->param('postsignin')); $session->clear("do");
$session->clear("postsignin"); IkiWiki::cgi_savesession($session);
$session->clear("do"); IkiWiki::redirect($q, $page);
IkiWiki::cgi_savesession($session); exit;
IkiWiki::redirect($q, $page); }
}
}
} }
sub auth ($$) {
# While this hook is not currently used, it needs to exist
# so ikiwiki knows that the wiki supports logins, and will
# enable the Preferences page.
}
1 1