@@ -10,6 +10,7 @@ use WGDev::X ();
10
10
11
11
sub config_options {
12
12
return qw(
13
+ delete
13
14
findByPassword=s
14
15
findByDictionary=s
15
16
) ;
@@ -28,6 +29,33 @@ sub process {
28
29
if ( my $dictionary = $self -> option(' findByDictionary' ) ) {
29
30
return $self -> find_by_dictionary($dictionary );
30
31
}
32
+
33
+ if ( $self -> option(' delete' ) ) {
34
+ return $self -> delete_user();
35
+ }
36
+ }
37
+
38
+ # this is named 'delete_user()' because 'delete' is a built-in function in Perl
39
+ sub delete_user {
40
+ my $self = shift ;
41
+ my $user = undef ;
42
+ my $wgd = $self -> wgd;
43
+ my $session = $wgd -> session();
44
+
45
+ if ( !$self -> arguments ) {
46
+ WGDev::X-> throw(" No user to delete!\n " );
47
+ }
48
+
49
+ foreach my $userId ( $self -> arguments ) {
50
+ eval {
51
+ $user = new WebGUI::User($session , $userId );
52
+ };
53
+ if ($@ || !$user -> validUserId($session , $userId )) {
54
+ WGDev::X::UserNotFound-> throw(userId => $userId );
55
+ }
56
+
57
+ $user -> delete ();
58
+ }
31
59
}
32
60
33
61
sub find_by_password {
@@ -89,7 +117,7 @@ sub find_by_dictionary {
89
117
90
118
=head1 SYNOPSIS
91
119
92
- wgd user [--findByPassword <password>] [--findByDictionary <dictionary>]
120
+ wgd user [--delete userId [userId ...]] [-- findByPassword <password>] [--findByDictionary <dictionary>]
93
121
94
122
=head1 DESCRIPTION
95
123
@@ -99,6 +127,10 @@ Utilities for manipulating WebGUI Users
99
127
100
128
=over 8
101
129
130
+ =item C<--delete >
131
+
132
+ Delete the specified user(s) by their userId.
133
+
102
134
=item C<--findByPassword >
103
135
104
136
Return a list of users that are using the given password (assumes
@@ -113,6 +145,10 @@ file in C</usr/share/dict/> or C</var/lib/dict/>
113
145
114
146
=back
115
147
148
+ =method delete_user
149
+
150
+ Deletes the specified user(s), given a list of userIds on the command line.
151
+
116
152
=method find_by_password
117
153
118
154
Hashes the given password and sees if any user IDs in the C<authentication > table
0 commit comments