Extension require login for page.cgi
rojanu
aliustek at gmail.com
Thu Mar 24 11:13:50 UTC 2011
Hi,
I am writing an extension to add a list assignees to components and am
using page.cgi to create new pages. I have following code but after
few minutes Bugzilla asks for login again.
Any ideas?
<code>
sub page_before_template {
my ($self, $args) = @_;
my $page = $args->{page_id};
my $vars = $args->{vars};
if ($page =~ m{^assigneelist/.*}) {
my $cgi = Bugzilla->cgi;
my $template = Bugzilla->template;
#
# Preliminary checks:
#
my $user = Bugzilla->login(LOGIN_REQUIRED);
print $cgi->header();
$user->in_group('editcomponents')
|| scalar(@{$user-
>get_products_by_permission('editcomponents')})
|| ThrowUserError("auth_failure", {group =>
"editcomponents",
action => "edit",
object => "components"});
#
# often used variables
#
my $product_name = trim($cgi->param('product') || '');
my $comp_name = trim($cgi->param('component') || '');
my $action = trim($cgi->param('action') || '');
my $showbugcounts = (defined $cgi->param('showbugcounts'));
#
# product = '' -> Show nice list of products
#
unless ($product_name) {
my $selectable_products = $user->get_selectable_products;
# If the user has editcomponents privs for some products
only,
# we have to restrict the list of products to display.
unless ($user->in_group('editcomponents')) {
$selectable_products = $user-
>get_products_by_permission('editcomponents');
}
$vars->{'products'} = $selectable_products;
$vars->{'showbugcounts'} = $showbugcounts;
$template->process("admin/components/select-
product.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
}
my $product = $user->check_can_admin_product($product_name);
#
# comp_name='' -> Show nice list of components
#
unless ($comp_name) {
$vars->{'showbugcounts'} = $showbugcounts;
$vars->{'product'} = $product;
$template->process("admin/components/list.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
}
$vars->{'product'} = $product;
$vars->{'comp'} =
Bugzilla::Component->check({ product => $product, name =>
$comp_name });
#
# User can edit given component, goto page requested
#
if ($page =~ m{^assigneelist/\.}) {
_page_assignees($vars);
}
elsif ($page =~ m{^assigneelist/group/list\.}) {
_page_assigneegroups($vars, $action);
}
}
}
</code>
_______________________________________________
dev-apps-bugzilla mailing list
dev-apps-bugzilla at lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-apps-bugzilla
More information about the developers
mailing list