[dw-free] suspend command doesn't work for feed accounts
[commit: http://hg.dwscoalition.org/dw-free/rev/3fa91526676e]
http://bugs.dwscoalition.org/show_bug.cgi?id=2454
Fix the suspend command to allow the suspension of feed accounts.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2454
Fix the suspend command to allow the suspension of feed accounts.
Patch by
Files modified:
- cgi-bin/LJ/Console/Command/Suspend.pm
- t/console-suspend.t
--------------------------------------------------------------------------------
diff -r 1198e89d8511 -r 3fa91526676e cgi-bin/LJ/Console/Command/Suspend.pm
--- a/cgi-bin/LJ/Console/Command/Suspend.pm Wed Apr 21 22:38:56 2010 +0000
+++ b/cgi-bin/LJ/Console/Command/Suspend.pm Wed Apr 21 22:46:23 2010 +0000
@@ -40,6 +40,7 @@ sub execute {
unless $user && $reason && scalar(@args) == 0;
my $remote = LJ::get_remote();
+ my $openid_only = $remote->has_priv( "suspend", "openid" ) && ! $remote->has_priv( "suspend", "*" );
my $entry = LJ::Entry->new_from_url($user);
if ($entry) {
@@ -47,7 +48,7 @@ sub execute {
my $journal = $entry->journal;
return $self->error("You are not authorized to suspend entries.")
- if $remote->has_priv( "suspend", "openid" );
+ if $openid_only;
return $self->error("Invalid entry.")
unless $entry->valid;
@@ -72,7 +73,7 @@ sub execute {
} else {
return $self->error( "You are not authorized to suspend by email address." )
- if $remote->has_priv( "suspend", "openid" );
+ if $openid_only;
$self->info("Acting on users matching email $user");
@@ -115,7 +116,7 @@ sub execute {
next;
}
- if ( $remote->has_priv( "suspend", "openid" ) && ! $u->is_identity ) {
+ if ( $openid_only && ! $u->is_identity ) {
$self->error( "$username is not an identity account." );
next;
}
diff -r 1198e89d8511 -r 3fa91526676e t/console-suspend.t
--- a/t/console-suspend.t Wed Apr 21 22:38:56 2010 +0000
+++ b/t/console-suspend.t Wed Apr 21 22:46:23 2010 +0000
@@ -7,7 +7,7 @@ use LJ::Test qw (temp_user);
use LJ::Test qw (temp_user);
local $LJ::T_NO_COMMAND_PRINT = 1;
-plan tests => 12;
+plan tests => 14;
my $u = temp_user();
my $u2 = temp_user();
@@ -24,8 +24,14 @@ LJ::set_remote($u);
is($run->("suspend " . $u2->user . " 'because'"),
"error: You are not authorized to run this command.");
-$u->grant_priv("suspend");
+$u->grant_priv( "suspend", "openid" );
+is($run->("suspend " . $u2->user . " 'because'"),
+ "error: " . $u2->user . " is not an identity account.");
+is($run->("suspend " . $u2->email_raw . " \"because\" confirm"),
+ "error: You are not authorized to suspend by email address.");
+
+$u->grant_priv( "suspend", "*" );
is($run->("suspend " . $u2->user . " \"because\""),
"success: User '" . $u2->user . "' suspended.");
$u2 = LJ::load_user($u2->user);
--------------------------------------------------------------------------------

no subject