How can I authenticate when using the Bugzilla Perl API in a script?

后端 未结 3 894
闹比i
闹比i 2021-01-13 16:39

Working from the Bugzilla API, I\'ve written a quick Perl script to clone a Bugzilla Product (recreating all the Components under their new Product). The Bugzilla Perl API i

3条回答
  •  滥情空心
    2021-01-13 17:21

    The following code snippet might enter the question. Here we check also that the user has the correct "editcomponents" credential.

    my $user = new Bugzilla::User({ name => $login })
      || ThrowUserError('invalid_username', { name => $login });
    
    
    # Authenticate using this user account.
    Bugzilla->set_user($user);
    $user->in_group('editcomponents')
          || ThrowUserError("auth_failure", {group  => "editcomponents",
                                             action => "add",
                                             object => "products"});
    

提交回复
热议问题