Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/CXGN/BrAPI/v2/ObservationVariables.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions lib/SGN/Controller/AJAX/BrAPI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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}))) {
Expand Down Expand Up @@ -3313,7 +3314,6 @@ sub observationvariable_list_POST {
my $self = shift;
my $c = shift;
my ($auth,$user_id) = _authenticate_user($c);
my $user_id;

my $response;
try {
Expand All @@ -3326,7 +3326,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);
Expand Down Expand Up @@ -3382,7 +3382,6 @@ sub observationvariable_detail_PUT {
my $c = shift;
my $variableDbId = shift;
my ($auth,$user_id) = _authenticate_user($c);
my $user_id;

my $response;
try {
Expand All @@ -3393,7 +3392,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')){
Expand Down