aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2020-10-16 15:11:50 +0100
committerStruan Donald <struan@exo.org.uk>2020-10-23 10:07:54 +0100
commit9150a5f72725d58055f9b5e60d339a781f9440f1 (patch)
tree0227f164d5ea60648bb108b4e400c56f8602370d /perllib
parent65b2893f9c2512e51d66885a393b77f84efa8330 (diff)
allow bulk removal of staff status from users
Bulk option to remove body, roles and permisions, and disable login in admin for users. Fixes mysociety/fixmystreet-commercial#2025
Diffstat (limited to 'perllib')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin/Users.pm30
1 files changed, 21 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin/Users.pm b/perllib/FixMyStreet/App/Controller/Admin/Users.pm
index a05e737ab..7ebfb9bbd 100644
--- a/perllib/FixMyStreet/App/Controller/Admin/Users.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin/Users.pm
@@ -29,17 +29,29 @@ sub index :Path : Args(0) {
if ($c->req->method eq 'POST') {
my @uids = $c->get_param_list('uid');
- my @role_ids = $c->get_param_list('roles');
my $user_rs = FixMyStreet::DB->resultset("User")->search({ id => \@uids });
- foreach my $user ($user_rs->all) {
- $user->admin_user_body_permissions->delete;
- $user->user_roles->search({
- role_id => { -not_in => \@role_ids },
- })->delete;
- foreach my $role (@role_ids) {
- $user->user_roles->find_or_create({
- role_id => $role,
+ if ( $c->get_param('remove-staff') ) {
+ foreach my $user ($user_rs->all) {
+ $user->update({
+ from_body => undef,
+ email_verified => 0,
+ phone_verified => 0,
});
+ $user->user_roles->delete;
+ $user->admin_user_body_permissions->delete;
+ }
+ } else {
+ my @role_ids = $c->get_param_list('roles');
+ foreach my $user ($user_rs->all) {
+ $user->admin_user_body_permissions->delete;
+ $user->user_roles->search({
+ role_id => { -not_in => \@role_ids },
+ })->delete;
+ foreach my $role (@role_ids) {
+ $user->user_roles->find_or_create({
+ role_id => $role,
+ });
+ }
}
}
$c->stash->{status_message} = _('Updated!');