blob: 69d165abb8e506326b487210fb4017bdd9dffb99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;
|