aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Script/CreateSuperuser.pm
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2016-07-20 09:32:55 +0100
committerDave Arter <davea@mysociety.org>2016-07-20 09:32:55 +0100
commit5e6d75814fc24da3d298df258989049a57c5d75f (patch)
treed1539cb97c1859594d115ad465df0de37f0b3721 /perllib/FixMyStreet/Script/CreateSuperuser.pm
parent65545553b5171f1ef1d611ea93c38f138451fb31 (diff)
parent5e8ac92d2a38d3ae3802bffee12111e164935b1d (diff)
Merge branch 'admin-using-normal-login'
Diffstat (limited to 'perllib/FixMyStreet/Script/CreateSuperuser.pm')
-rw-r--r--perllib/FixMyStreet/Script/CreateSuperuser.pm25
1 files changed, 25 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Script/CreateSuperuser.pm b/perllib/FixMyStreet/Script/CreateSuperuser.pm
new file mode 100644
index 000000000..69d165abb
--- /dev/null
+++ b/perllib/FixMyStreet/Script/CreateSuperuser.pm
@@ -0,0 +1,25 @@
+package FixMyStreet::Script::CreateSuperuser;
+
+use strict;
+use warnings;
+
+use FixMyStreet;
+use FixMyStreet::DB;
+
+sub createsuperuser {
+ die "Specify a single email address and optionally password to create a superuser or grant superuser status to." if (@ARGV < 1 || @ARGV > 2);
+
+ my $user = FixMyStreet::DB->resultset('User')->find_or_new({ email => $ARGV[0] });
+ if ( !$user->in_storage ) {
+ die "Specify a password for this new user." if (@ARGV < 2);
+ $user->password($ARGV[1]);
+ $user->is_superuser(1);
+ $user->insert;
+ } else {
+ $user->update({ is_superuser => 1 });
+ }
+ print $user->email . " is now a superuser.\n";
+}
+
+
+1; \ No newline at end of file