diff --git a/src/script/hydra-create-user b/src/script/hydra-create-user index bbfa6558..3b564cb3 100755 --- a/src/script/hydra-create-user +++ b/src/script/hydra-create-user @@ -15,6 +15,7 @@ Usage: $0 NAME [--full-name FULLNAME] [--email-address EMAIL-ADDRESS] [--password PASSWORD] + [--password-hash SHA1-HASH] [--wipe-roles] [--role ROLE]... @@ -30,7 +31,7 @@ EOF exit 0; } -my ($renameFrom, $type, $fullName, $emailAddress, $password); +my ($renameFrom, $type, $fullName, $emailAddress, $password, $passwordHash); my $wipeRoles = 0; my @roles; @@ -39,6 +40,7 @@ GetOptions("rename-from=s" => \$renameFrom, "full-name=s" => \$fullName, "email-address=s" => \$emailAddress, "password=s" => \$password, + "password-hash=s" => \$passwordHash, "wipe-roles" => \$wipeRoles, "role=s" => \@roles, "help" => sub { showHelp() } @@ -77,10 +79,15 @@ txn_do($db, sub { if defined $emailAddress; die "$0: Google accounts do not have a password.\n" if defined $password; + die "$0: Google accounts do not have a password.\n" + if defined $passwordHash; $user->update({ emailaddress => $userName, password => "!" }); } else { $user->update({ emailaddress => $emailAddress }) if defined $emailAddress; - $user->update({ password => sha1_hex($password) }) if defined $password; + if (defined $password && !(defined $passwordHash)) { + $passwordHash = sha1_hex($password); + } + $user->update({ password => $passwordHash }) if defined $passwordHash; } $user->userroles->delete if $wipeRoles;