]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1523404 - Cannot clear all scopes when editing an oauth2 client. Throws DB error
authordklawren <dklawren@users.noreply.github.com>
Mon, 4 Feb 2019 19:00:12 +0000 (14:00 -0500)
committerGitHub <noreply@github.com>
Mon, 4 Feb 2019 19:00:12 +0000 (14:00 -0500)
Bugzilla/App/OAuth2/Clients.pm
template/en/default/admin/oauth/create.html.tmpl
template/en/default/admin/oauth/edit.html.tmpl

index 1dc53cc20040e9eff68970f80ed9943c783b2e5e..66a5dad4050b7d473ff14702b4e3539477896ae7 100644 (file)
@@ -9,7 +9,7 @@ package Bugzilla::App::OAuth2::Clients;
 use 5.10.1;
 use Mojo::Base 'Mojolicious::Controller';
 
-use List::Util qw(first);
+use List::Util qw(any first);
 use Bugzilla::Constants;
 use Bugzilla::Error;
 use Bugzilla::Token;
@@ -68,14 +68,13 @@ sub create {
   my $id          = $self->param('id');
   my $secret      = $self->param('secret');
   my @scopes      = $self->param('scopes');
-  $description || ThrowCodeError('param_required', {param => 'description'});
-  $id          || ThrowCodeError('param_required', {param => 'id'});
-  $secret      || ThrowCodeError('param_required', {param => 'secret'});
-  @scopes      || ThrowCodeError('param_required', {param => 'scopes'});
+  $description or ThrowCodeError('param_required', {param => 'description'});
+  $id          or ThrowCodeError('param_required', {param => 'id'});
+  $secret      or ThrowCodeError('param_required', {param => 'secret'});
+  any { $_ > 0 } @scopes or ThrowCodeError('param_required', {param => 'scopes'});
   my $token = $self->param('token');
   check_token_data($token, 'create_oauth_client');
 
-
   $dbh->do('INSERT INTO oauth2_client (client_id, description, secret) VALUES (?, ?, ?)',
     undef, $id, $description, $secret);
 
index f9f5973b908c9e5bf4586322ae2389221390a319..4190a09d92d0313f1cc6ea5e69597b98374f50c1 100644 (file)
@@ -20,6 +20,7 @@
     <tr>
       <th class="field_label"><label for="scopes">Scopes:</label></th>
       <td>
+        At least one required<br>
         <table>
         [% FOREACH scope = scopes %]
           <tr>
index 09ceadf920b019bb52e6569665080ce8a7168f35..3d1f5570f61947b295bae3b7c2d00b2be90f7be5 100644 (file)
@@ -26,6 +26,7 @@
     <tr>
       <th class="field_label"><label for="scopes">Scopes:</label></th>
       <td>
+        At least one required<br>
         <table>
         [% FOREACH scope = scopes %]
           <tr>