]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/emailauth.pm
In rebuilds, assume that every page has been scanned by the time the scan phase ends
[git.ikiwiki.info.git] / IkiWiki / Plugin / emailauth.pm
index 57100a2d74915c5c6537984b7b45e67e71abac07..a589199d3d85a2cac98800657224f778734e3500 100644 (file)
@@ -8,7 +8,8 @@ use IkiWiki 3.00;
 
 sub import {
        hook(type => "getsetup", id => "emailauth", "call" => \&getsetup);
-       hook(type => "cgi", id => "cgi", "call" => \&cgi);
+       hook(type => "cgi", id => "emailauth", "call" => \&cgi);
+       hook(type => "formbuilder_setup", id => "emailauth", "call" => \&formbuilder_setup);
        IkiWiki::loadplugin("loginselector");
        IkiWiki::Plugin::loginselector::register_login_plugin(
                "emailauth",
@@ -77,12 +78,14 @@ sub email_auth ($$$$) {
        
        eval q{use Mail::Sendmail};
        error($@) if $@;
+       my $shorturl=$config{url};
+       $shorturl=~s/^https?:\/\///i;
        sendmail(
                To => $email,
                From => "$config{wikiname} admin <".
                        (defined $config{adminemail} ? $config{adminemail} : "")
                        .">",
-               Subject => "$config{wikiname} login",
+               Subject => "$config{wikiname} login | $shorturl",
                Message => $template->output,
        ) or error(gettext("Failed to send mail"));
 
@@ -111,6 +114,17 @@ sub cgi ($$) {
        }
 }
 
+sub formbuilder_setup (@) {
+       my %params=@_;
+       my $form=$params{form};
+       my $session=$params{session};
+
+       if ($form->title eq "preferences" &&
+           IkiWiki::emailuser($session->param("name"))) {
+               $form->field(name => "email", disabled => 1);
+       }
+}
+
 # Generates the token that will be used in the authurl to log the user in.
 # This needs to be hard to guess, and relatively short. Generating a cgi
 # session id will make it as hard to guess as any cgi session.