X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/70cf5bb7654a551511c0b05cd782349dbbde2c78..6c546c8f3182668c6d21d578b789674894f18c39:/IkiWiki/Plugin/emailauth.pm diff --git a/IkiWiki/Plugin/emailauth.pm b/IkiWiki/Plugin/emailauth.pm index aa067238f..becf40ca5 100644 --- a/IkiWiki/Plugin/emailauth.pm +++ b/IkiWiki/Plugin/emailauth.pm @@ -26,6 +26,12 @@ sub getsetup () { rebuild => 0, section => "auth", }, + emailauth_sender => { + type => "string", + description => "email address to send emailauth mails as (default: adminemail)", + safe => 1, + rebuild => 0, + }, } sub email_setup ($$) { @@ -70,7 +76,7 @@ sub email_auth ($$$$) { $template->param( wikiname => $config{wikiname}, # Intentionally using short field names to keep link short. - authurl => IkiWiki::cgiurl_abs( + authurl => IkiWiki::cgiurl_abs_samescheme( 'e' => $email, 'v' => $token, ), @@ -78,14 +84,18 @@ sub email_auth ($$$$) { eval q{use Mail::Sendmail}; error($@) if $@; + my $shorturl=$config{url}; + $shorturl=~s/^https?:\/\///i; + my $emailauth_sender=$config{emailauth_sender}; + $emailauth_sender=$config{adminemail} unless defined $emailauth_sender; sendmail( To => $email, From => "$config{wikiname} admin <". - (defined $config{adminemail} ? $config{adminemail} : "") + (defined $emailauth_sender ? $emailauth_sender : "") .">", - Subject => "$config{wikiname} login", + Subject => "$config{wikiname} login | $shorturl", Message => $template->output, - ) or error(gettext("Failed to send mail")); + ) or error(sprintf(gettext("Failed to send mail: %s"), $Mail::Sendmail::error)); $infodisplayer->(gettext("You have been sent an email, with a link you can open to complete the login process.")); } @@ -138,7 +148,7 @@ sub gentoken ($$) { my $session=shift; eval q{use CGI::Session}; error($@) if $@; - my $token = CGI::Session->new->id; + my $token = CGI::Session->new("driver:DB_File", undef, {FileName => "/dev/null"})->id; IkiWiki::userinfo_set($email, "emailauthexpire", time+(60*60*24)); IkiWiki::userinfo_set($email, "emailauth", $token); IkiWiki::userinfo_set($email, "emailauthpostsignin", defined $session->param("postsignin") ? $session->param("postsignin") : "");