From d1d8acd8e035f5e37bd40d83632f69321665ed5c Mon Sep 17 00:00:00 2001 From: Nick Palladino Date: Thu, 18 Mar 2021 11:41:28 -0400 Subject: [PATCH 1/3] Remove used_id parameter that was messing up trait saves --- lib/SGN/Controller/AJAX/BrAPI.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/SGN/Controller/AJAX/BrAPI.pm b/lib/SGN/Controller/AJAX/BrAPI.pm index 4ba22f2559..e52189f127 100644 --- a/lib/SGN/Controller/AJAX/BrAPI.pm +++ b/lib/SGN/Controller/AJAX/BrAPI.pm @@ -3313,7 +3313,6 @@ sub observationvariable_list_POST { my $self = shift; my $c = shift; my ($auth,$user_id) = _authenticate_user($c); - my $user_id; my $response; try { @@ -3326,7 +3325,7 @@ sub observationvariable_list_POST { my $brapi = $self->brapi_module; my $brapi_module = $brapi->brapi_wrapper('ObservationVariables'); - $response = $brapi_module->store(\@all_variables,$user_id, $c); + $response = $brapi_module->store(\@all_variables, $c); } catch { if ($_->isa('CXGN::BrAPI::Exceptions::ConflictException')){ my $error = CXGN::BrAPI::JSONResponse->return_error([], $_->message); @@ -3382,7 +3381,6 @@ sub observationvariable_detail_PUT { my $c = shift; my $variableDbId = shift; my ($auth,$user_id) = _authenticate_user($c); - my $user_id; my $response; try { @@ -3393,7 +3391,7 @@ sub observationvariable_detail_PUT { my $brapi = $self->brapi_module; my $brapi_module = $brapi->brapi_wrapper('ObservationVariables'); - $response = $brapi_module->update($data,$user_id,$c); + $response = $brapi_module->update($data,$c); } catch { warn Dumper($_); if ($_->isa('CXGN::BrAPI::Exceptions::NotFoundException')){ From d3c8a8bdfc7c31df5696f607a3c3063cb81f8661 Mon Sep 17 00:00:00 2001 From: Nick Palladino Date: Thu, 18 Mar 2021 11:58:25 -0400 Subject: [PATCH 2/3] Fix pagination for get variables --- lib/CXGN/BrAPI/v2/ObservationVariables.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/CXGN/BrAPI/v2/ObservationVariables.pm b/lib/CXGN/BrAPI/v2/ObservationVariables.pm index 86199d4271..a8aa928b2b 100644 --- a/lib/CXGN/BrAPI/v2/ObservationVariables.pm +++ b/lib/CXGN/BrAPI/v2/ObservationVariables.pm @@ -251,9 +251,8 @@ sub get_query { my @data_files; if ($array) { - my $data_window; - ($data_window, $pagination) = CXGN::BrAPI::Pagination->paginate_array(\@variables, $page_size, $page); - %result = (data => $data_window); + my %result = (data=>\@variables); + my $pagination = CXGN::BrAPI::Pagination->pagination_response($total_count,$page_size,$page); return CXGN::BrAPI::JSONResponse->return_success(\%result, $pagination, \@data_files, $status, 'Observationvariable search result constructed'); } else { $pagination = CXGN::BrAPI::Pagination->pagination_response($total_count,$page_size,$page); From adefb6cb3da6ba775c3428505a01a2237d3e7cce Mon Sep 17 00:00:00 2001 From: Nick Palladino Date: Mon, 19 Apr 2021 10:49:44 -0400 Subject: [PATCH 3/3] Not sure about this but needed user info downstream --- lib/SGN/Controller/AJAX/BrAPI.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/SGN/Controller/AJAX/BrAPI.pm b/lib/SGN/Controller/AJAX/BrAPI.pm index e52189f127..54bd331d3d 100644 --- a/lib/SGN/Controller/AJAX/BrAPI.pm +++ b/lib/SGN/Controller/AJAX/BrAPI.pm @@ -206,10 +206,11 @@ sub _authenticate_user { $server_permission{$wildcard} = 1; } + ($user_id, $user_type, $user_pref, $expired) = CXGN::Login->new($c->dbc->dbh)->query_from_cookie($c->stash->{session_token}); + # If our brapi config is set to authenticate or the controller calling this asks for forcing of # authentication or serverinfo call method request auth, we authenticate. if ($c->config->{brapi_require_login} == 1 || $force_authenticate || !exists($server_permission{$wildcard})){ - ($user_id, $user_type, $user_pref, $expired) = CXGN::Login->new($c->dbc->dbh)->query_from_cookie($c->stash->{session_token}); #print STDERR $user_id." : ".$user_type." : ".$expired; if (!$user_id || $expired || !$user_type || (!exists($server_permission{$user_type}) && !exists($server_permission{$wildcard}))) {