# 'url' => 'http://castaway.myopenid.com/',
my $username = $userinfo->{url} || $userinfo->{username};
- return $self->lookup(Text::Tradition::User->id_for_user($username));
+ ## No logins if user is deactivated (use lookup to fetch to re-activate)
+ my $user = $self->lookup(Text::Tradition::User->id_for_user($username));
+ return if($user && !$user->active);
+
+ return $user;
}
return if !$username;
- my $user = $self->find_user({ username => $username });
+ my $user = $self->lookup(Text::Tradition::User->id_for_user($username));
return if !$user;
return $user if $user->active;
't|tradition:s' => \$tradition_id,
) or usage();
-if(!$command || !($command ~~ [qw/add modify delete deactivate reactivate/])) {
+if(!$command || !($command ~~ [qw/add modify delete deactivate reactivate list/])) {
print "No command supplied, chickening out ... \n\n";
usage();
}
}
}
+ when ('list') {
+ my $user = $userstore->find_user({ username => $username });
+ if(!$user) {
+ print "Can't find user '$username'\n";
+ break;
+ }
+ my $traditions = $user->traditions;
+
+ print "User: $username\n";
+ print "Has traditions: \n";
+ foreach my $t (@$traditions) {
+ print " ", $t->name, "\n";
+ }
+ print "OK.\n";
+ }
+
when ('deactivate') {
my $user = $userstore->deactivate_user({ username => $username});
if(!$user) {
admin_user.pl -c modify -u jimbob -t "mytradition"
+ admin_user.pl -c list -u jimbob
+
admin_user.pl -c delete -u jimbob
=head1 OPTIONS
=item -c | --command
-The action to take, can be one of: add, modify, deactivate, reactivate, delete.
+The action to take, can be one of: add, modify, deactivate, reactivate, delete, list.
+
+=over
+
+=item add
+
+Create a new user and store it in the Directory
+
+=item modify
+
+Change an existing stored user, with a -p this will change the user's
+password, with a -t will add or remove the named tradition from the
+user.
+
+=item list
+
+List the given user's traditions.
+
+=item deactivate
+
+Deactivate this user.
+
+=item reactivate
+
+Re-activate this user.
+
+=item delete
+
+Delete the user permanently.
+
+=back
=item -u | --username
my $d_user = $user_store->deactivate_user({ username => 'testactive' });
is($d_user->active, 0, 'Deactivated user');
+ is($user_store->find_user({ username => 'testactive' }), undef, 'Deactivated user not returned by find_user');
## TODO - add test where user has traditions to start with
}
my $user = $user_store->add_user({ username => 'testinactive',
password => 'imaninactiveuser' });
- my $d_user = $user_store->deactivate_user({ username => 'testactive' });
+ my $d_user = $user_store->deactivate_user({ username => 'testinactive' });
ok(!$d_user->active, 'Deactivate test user starts active');
my $a_user = $user_store->reactivate_user({ username => 'testinactive' });
is($a_user->active, 1, 'Re-activated user');
+ ok($user_store->find_user({ username => 'testinactive' }), 'Re-activated user returned by find_user again');
}
{