diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-05-13 18:50:40 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-05-13 18:50:40 -0400 |
commit | e34533d1a0e0fc90a669f7cb3c11cafc6b285b26 (patch) | |
tree | daec6a9fe3b54808cc755fb9f85f992c5a619800 /IkiWiki/Plugin | |
parent | 5b459737a50d83ff94490d86d1b9a4438d4b50a1 (diff) | |
download | ikiwiki-e34533d1a0e0fc90a669f7cb3c11cafc6b285b26.tar ikiwiki-e34533d1a0e0fc90a669f7cb3c11cafc6b285b26.tar.gz |
email auth plugin now works through email address entry
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/emailauth.pm | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/emailauth.pm b/IkiWiki/Plugin/emailauth.pm new file mode 100644 index 000000000..62c9fe877 --- /dev/null +++ b/IkiWiki/Plugin/emailauth.pm @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# Ikiwiki email address as login +package IkiWiki::Plugin::emailauth; + +use warnings; +use strict; +use IkiWiki 3.00; + +sub import { + hook(type => "getsetup", id => "emailauth", "call" => \&getsetup); + hook(type => "auth", id => "emailauth", call => \&auth); + IkiWiki::loadplugin("loginselector"); + IkiWiki::Plugin::loginselector::register_login_plugin( + "emailauth", + \&email_setup, + \&email_check_input, + \&email_auth, + ); +} + +sub getsetup () { + return + plugin => { + safe => 1, + rebuild => 0, + section => "auth", + }, +} + +sub email_setup ($$) { + my $q=shift; + my $template=shift; + + return 1; +} + +sub email_check_input ($) { + my $cgi=shift; + defined $cgi->param('do') + && $cgi->param("do") eq "signin" + && defined $cgi->param('Email_entry') + && length $cgi->param('Email_entry'); +} + +sub email_auth ($$$) { + my $cgi=shift; + my $session=shift; + my $errordisplayer=shift; + + unless ($cgi->param('Email_entry') =~ /.\@./) { + $errordisplayer->("Invalid email address."); + return; + } + + error "EMAIL AUTH"; +} + +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 |