]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/emailauth.pm
62c9fe877d733958c56b8413a875f9385cd8e333
[git.ikiwiki.info.git] / IkiWiki / Plugin / emailauth.pm
1 #!/usr/bin/perl
2 # Ikiwiki email address as login
3 package IkiWiki::Plugin::emailauth;
5 use warnings;
6 use strict;
7 use IkiWiki 3.00;
9 sub import {
10         hook(type => "getsetup", id => "emailauth", "call" => \&getsetup);
11         hook(type => "auth", id => "emailauth", call => \&auth);
12         IkiWiki::loadplugin("loginselector");
13         IkiWiki::Plugin::loginselector::register_login_plugin(
14                 "emailauth",
15                 \&email_setup,
16                 \&email_check_input,
17                 \&email_auth,
18         );
19 }
21 sub getsetup () {
22         return
23                 plugin => {
24                         safe => 1,
25                         rebuild => 0,
26                         section => "auth",
27                 },
28 }
30 sub email_setup ($$) {
31         my $q=shift;
32         my $template=shift;
34         return 1;
35 }
37 sub email_check_input ($) {
38         my $cgi=shift;
39         defined $cgi->param('do')
40                 && $cgi->param("do") eq "signin"
41                 && defined $cgi->param('Email_entry')
42                 && length $cgi->param('Email_entry');
43 }
45 sub email_auth ($$$) {
46         my $cgi=shift;
47         my $session=shift;
48         my $errordisplayer=shift;
49         
50         unless ($cgi->param('Email_entry') =~ /.\@./) {
51                 $errordisplayer->("Invalid email address.");
52                 return;
53         }
55         error "EMAIL AUTH";
56 }
58 sub auth ($$) {
59         # While this hook is not currently used, it needs to exist
60         # so ikiwiki knows that the wiki supports logins, and will
61         # enable the Preferences page.
62 }
64 1