Commit 39633788 authored by kiko%async.com.br's avatar kiko%async.com.br

Fix for bug 236678: Clean up access to COOKIE global. Murder the last

remaining places in the tree where COOKIE is used; includes a rather thorough cleanup of Bugzilla::Bug->user and a minor doc update. r=joel, a=justdave.
parent 1176bd8d
...@@ -87,13 +87,10 @@ sub logout_user_by_id { ...@@ -87,13 +87,10 @@ sub logout_user_by_id {
# hack that invalidates credentials for a single request # hack that invalidates credentials for a single request
sub logout_request { sub logout_request {
undef $_user; undef $_user;
# XXX clean this up eventually
$::userid = 0; $::userid = 0;
# XXX clean these up eventually # We can't delete from $cgi->cookie, so logincookie data will remain
delete $::COOKIE{"Bugzilla_login"}; # there. Don't rely on it: use Bugzilla->user->login instead!
# NB - Can't delete from $cgi->cookie, so the logincookie data will
# remain there; it's only used in Bugzilla::Auth::CGI->logout anyway
# People shouldn't rely on the cookie param for the username
# - use Bugzilla->user instead!
} }
my $_dbh; my $_dbh;
......
...@@ -130,9 +130,3 @@ Bugzilla.pm ...@@ -130,9 +130,3 @@ Bugzilla.pm
a reorganization which moves CGI-specific code to a subdirectory, a reorganization which moves CGI-specific code to a subdirectory,
Bugzilla.pm should go with it. Bugzilla.pm should go with it.
$::COOKIE
There are still instances of use of $::COOKIE to obtain Logincookie
information; these should be removed as well.
...@@ -387,32 +387,32 @@ sub user { ...@@ -387,32 +387,32 @@ sub user {
my $self = shift; my $self = shift;
return $self->{'user'} if exists $self->{'user'}; return $self->{'user'} if exists $self->{'user'};
$self->{'user'} = {}; use Bugzilla;
my $movers = Param("movers"); my @movers = map { trim $_ } split(",", Param("movers"));
$movers =~ s/\s?,\s?/|/g; my $canmove = Param("move-enabled") && Bugzilla->user &&
$movers =~ s/@/\@/g; (lsearch(\@movers, Bugzilla->user->login) != -1);
$self->{'user'}->{'canmove'} = Param("move-enabled")
&& (defined $::COOKIE{"Bugzilla_login"}) # In the below, if the person hasn't logged in, then we treat them
&& ($::COOKIE{"Bugzilla_login"} =~ /$movers/); # as if they can do anything. That's because we don't know why they
# haven't logged in; it may just be because they don't use cookies.
# In the below, if the person hasn't logged in ($::userid == 0), then # Display everything as if they have all the permissions in the
# we treat them as if they can do anything. That's because we don't # world; their permissions will get checked when they log in and
# know why they haven't logged in; it may just be because they don't # actually try to make the change.
# use cookies. Display everything as if they have all the permissions my $privileged = (!Bugzilla->user)
# in the world; their permissions will get checked when they log in || Bugzilla->user->in_group("editbugs")
# and actually try to make the change. || Bugzilla->user->id == $self->{'assigned_to'}{'id'}
$self->{'user'}->{'canedit'} = $::userid == 0 || (Param('useqacontact') && $self->{'qa_contact'} &&
|| $::userid == $self->{'reporter'}{'id'} Bugzilla->user->id == $self->{'qa_contact'}{'id'});
|| (Param('useqacontact') && $self->{'qa_contact'} && $::userid == $self->{'qa_contact'}{'id'}) my $isreporter = Bugzilla->user &&
|| $::userid == $self->{'assigned_to'}{'id'} Bugzilla->user->id == $self->{'reporter'}{'id'};
|| &::UserInGroup("editbugs");
$self->{'user'}->{'canconfirm'} = $::userid == 0 my $canedit = $privileged || $isreporter;
|| ($self->{'qa_contact'} && $::userid == $self->{'qa_contact'}{'id'}) my $canconfirm = $privileged || Bugzilla->user->in_group("canconfirm");
|| $::userid == $self->{'assigned_to'}{'id'}
|| &::UserInGroup("editbugs") $self->{'user'} = {canmove => $canmove,
|| &::UserInGroup("canconfirm"); canconfirm => $canconfirm,
canedit => $canedit,};
return $self->{'user'}; return $self->{'user'};
} }
......
...@@ -421,10 +421,6 @@ foreach my $name ($::cgi->param()) { ...@@ -421,10 +421,6 @@ foreach my $name ($::cgi->param()) {
$::buffer = $::cgi->query_string(); $::buffer = $::cgi->query_string();
foreach my $name ($::cgi->cookie()) {
$::COOKIE{$name} = $::cgi->cookie($name);
}
# This could be needed in any CGI, so we set it here. # This could be needed in any CGI, so we set it here.
$vars->{'help'} = $::cgi->param('help') ? 1 : 0; $vars->{'help'} = $::cgi->param('help') ? 1 : 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment