]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/emailauth.pm
add emailauth.tmpl
[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         IkiWiki::loadplugin("loginselector");
12         IkiWiki::Plugin::loginselector::register_login_plugin(
13                 "emailauth",
14                 \&email_setup,
15                 \&email_check_input,
16                 \&email_auth,
17         );
18 }
20 sub getsetup () {
21         return
22                 plugin => {
23                         safe => 1,
24                         rebuild => 0,
25                         section => "auth",
26                 },
27 }
29 sub email_setup ($$) {
30         my $q=shift;
31         my $template=shift;
33         return 1;
34 }
36 sub email_check_input ($) {
37         my $cgi=shift;
38         defined $cgi->param('do')
39                 && $cgi->param("do") eq "signin"
40                 && defined $cgi->param('Email_entry')
41                 && length $cgi->param('Email_entry');
42 }
44 sub email_auth ($$$) {
45         my $cgi=shift;
46         my $session=shift;
47         my $errordisplayer=shift;
48         
49         unless ($cgi->param('Email_entry') =~ /.\@./) {
50                 $errordisplayer->("Invalid email address.");
51                 return;
52         }
54         error "EMAIL AUTH";
55 }
57 1