From: dklawren Date: Mon, 4 Feb 2019 19:00:12 +0000 (-0500) Subject: Bug 1523404 - Cannot clear all scopes when editing an oauth2 client. Throws DB error X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=08abdf32b03ec634e8946549c1e6256bfa3f847f;p=thirdparty%2Fbugzilla.git Bug 1523404 - Cannot clear all scopes when editing an oauth2 client. Throws DB error --- diff --git a/Bugzilla/App/OAuth2/Clients.pm b/Bugzilla/App/OAuth2/Clients.pm index 1dc53cc20..66a5dad40 100644 --- a/Bugzilla/App/OAuth2/Clients.pm +++ b/Bugzilla/App/OAuth2/Clients.pm @@ -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); diff --git a/template/en/default/admin/oauth/create.html.tmpl b/template/en/default/admin/oauth/create.html.tmpl index f9f5973b9..4190a09d9 100644 --- a/template/en/default/admin/oauth/create.html.tmpl +++ b/template/en/default/admin/oauth/create.html.tmpl @@ -20,6 +20,7 @@ + At least one required
[% FOREACH scope = scopes %] diff --git a/template/en/default/admin/oauth/edit.html.tmpl b/template/en/default/admin/oauth/edit.html.tmpl index 09ceadf92..3d1f5570f 100644 --- a/template/en/default/admin/oauth/edit.html.tmpl +++ b/template/en/default/admin/oauth/edit.html.tmpl @@ -26,6 +26,7 @@
+ At least one required
[% FOREACH scope = scopes %]