diff options
author | Joey Hess <joey@kitenet.net> | 2012-04-02 13:39:29 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-04-02 13:45:39 -0400 |
commit | c885ec66e0ffeefb41462b87707f5e80c0ffa993 (patch) | |
tree | 50d6bef132f6d057a42d2a7e69be68b28bf19f7e /IkiWiki/Plugin/notifyemail.pm | |
parent | c16b1e638e3ccc936ec24daa8419d64c4f6d5016 (diff) | |
download | ikiwiki-c885ec66e0ffeefb41462b87707f5e80c0ffa993.tar ikiwiki-c885ec66e0ffeefb41462b87707f5e80c0ffa993.tar.gz |
allow users to subscribe to comments w/o registering
Technically, when the user does this, a passwordless account is created
for them. The notify mails include a login url, and once logged in that
way, the user can enter a password to get a regular account (although
one with an annoying username).
This all requires the passwordauth plugin is enabled. A future enhancement
could be to split the passwordless user concept out into a separate plugin.
Diffstat (limited to 'IkiWiki/Plugin/notifyemail.pm')
-rw-r--r-- | IkiWiki/Plugin/notifyemail.pm | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/notifyemail.pm b/IkiWiki/Plugin/notifyemail.pm index 9f5a255ae..2c1775f2e 100644 --- a/IkiWiki/Plugin/notifyemail.pm +++ b/IkiWiki/Plugin/notifyemail.pm @@ -62,6 +62,19 @@ sub subscribe ($$) { length $pagespec ? $pagespec." or ".$addpagespec : $addpagespec); } +# Called by other plugins to subscribe an email to a pagespec. +sub anonsubscribe ($$) { + my $email=shift; + my $addpagespec=shift; + if (IkiWiki::Plugin::passwordauth->can("anonuser")) { + my $user=IkiWiki::Plugin::passwordauth::anonuser($email); + if (! defined $user) { + error(gettext("Cannot subscribe your email address without logging in.")); + } + subscribe($user, $addpagespec); + } +} + sub notify (@) { my @files=@_; return unless @files; @@ -123,11 +136,20 @@ sub notify (@) { if (pagetype($file) eq '_comment') { $subject=gettext("comment notification:")." ".$pagedesc; } + my $prefsurl=IkiWiki::cgiurl_abs(do => 'prefs'); + if (IkiWiki::Plugin::passwordauth->can("anonusertoken")) { + my $token=IkiWiki::Plugin::passwordauth::anonusertoken($userinfo->{$user}); + $prefsurl=IkiWiki::cgiurl_abs( + do => 'tokenauth', + name => $user, + token => $token, + ) if defined $token; + } my $template=template("notifyemail.tmpl"); $template->param( wikiname => $config{wikiname}, url => $url, - prefsurl => IkiWiki::cgiurl_abs(do => 'prefs'), + prefsurl => $prefsurl, showcontent => $showcontent, content => $content, ); |