From 22339188e7fac70362f024402ae873f51a36d578 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 13 May 2015 23:07:29 -0400 Subject: allow adminuser to be an email address --- IkiWiki/Setup/Automator.pm | 50 ++++++++++++++++++++++++---------------------- auto.setup | 2 +- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/IkiWiki/Setup/Automator.pm b/IkiWiki/Setup/Automator.pm index a8b04d966..9239974ad 100644 --- a/IkiWiki/Setup/Automator.pm +++ b/IkiWiki/Setup/Automator.pm @@ -154,31 +154,33 @@ sub import (@) { foreach my $admin (@{$config{adminuser}}) { next if defined IkiWiki::openiduser($admin); - # Prompt for password w/o echo. - my ($password, $password2); - system('stty -echo 2>/dev/null'); - local $|=1; - print "\n\nCreating wiki admin $admin ...\n"; - for (;;) { - print "Choose a password: "; - chomp($password=); - print "\n"; - print "Confirm password: "; - chomp($password2=); - - last if $password2 eq $password; - - print "Password mismatch.\n\n"; - } - print "\n\n\n"; - system('stty sane 2>/dev/null'); + if (! defined IkiWiki::emailuser($admin)) { + # Prompt for password w/o echo. + my ($password, $password2); + system('stty -echo 2>/dev/null'); + local $|=1; + print "\n\nCreating wiki admin $admin ...\n"; + for (;;) { + print "Choose a password: "; + chomp($password=); + print "\n"; + print "Confirm password: "; + chomp($password2=); + + last if $password2 eq $password; + + print "Password mismatch.\n\n"; + } + print "\n\n\n"; + system('stty sane 2>/dev/null'); - if (IkiWiki::userinfo_setall($admin, { regdate => time }) && - IkiWiki::Plugin::passwordauth::setpassword($admin, $password)) { - IkiWiki::userinfo_set($admin, "email", $config{adminemail}) if defined $config{adminemail}; - } - else { - error("problem setting up $admin user"); + if (IkiWiki::userinfo_setall($admin, { regdate => time }) && + IkiWiki::Plugin::passwordauth::setpassword($admin, $password)) { + IkiWiki::userinfo_set($admin, "email", $config{adminemail}) if defined $config{adminemail}; + } + else { + error("problem setting up $admin user"); + } } } diff --git a/auto.setup b/auto.setup index 843b4193a..1bcac36cb 100644 --- a/auto.setup +++ b/auto.setup @@ -18,7 +18,7 @@ our $wikiname_short=IkiWiki::Setup::Automator::sanitize_wikiname($wikiname); our $rcs=IkiWiki::Setup::Automator::ask( gettext("What revision control system to use?"), "git"); our $admin=IkiWiki::Setup::Automator::ask( - gettext("Which user (wiki account or openid) will be admin?"), $ENV{USER}); + gettext("Which user (wiki account, openid, or email) will be admin?"), $ENV{USER}); use Net::Domain q{hostfqdn}; our $domain=hostfqdn() || IkiWiki::Setup::Automator::ask( gettext("What is the domain name of the web server?"), ""); -- cgit v1.2.3