Skip to content
Merged
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
9 changes: 8 additions & 1 deletion src/MGRAST/lib/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,18 @@ sub authenticate {
$ustruct = globus_token($key);
if ($ustruct) {
if ($ustruct->{access_token}) {
my $info = { token => $ustruct->{access_token} };
if ($cgi->param('verbosity') && $cgi->param('verbosity') eq 'verbose') {
my $verb = globus_info($ustruct->{access_token});
foreach my $key (keys(%$verb)) {
$info->{$key} = $verb->{$key};
}
}
print $cgi->header(-type => 'application/json',
-status => 200,
-charset => 'UTF-8',
-Access_Control_Allow_Origin => '*' );
print '{ "token": "'.$ustruct->{access_token}.'" }';
print $json->encode($info);
exit;
} else {
return (undef, "invalid globus online credentials");
Expand Down
16 changes: 8 additions & 8 deletions src/MGRAST/lib/WebPage/PublishGenome.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use MGRAST::Metadata;

use JSON;
use LWP::UserAgent;
use HTTP::Request;
use Data::Dumper;

use WebConfig;
Expand Down Expand Up @@ -247,22 +248,21 @@ sub publish {
$json->allow_nonref;

my $url = $self->data('api')."/job/public";
my @args = (
($user && (! $job->public)) ? ('auth', $Conf::api_key) : (),
'Content_Type', 'multipart/form-data',
'Content', {metagenome_id => 'mgm'.$job->{metagenome_id}}
);
my $data = {metagenome_id => 'mgm'.$job->{metagenome_id}};
my $req = HTTP::Request->new(POST => $url);
$req->header('Content-Type' => 'application/json', 'auth' => $Conf::api_key);
$req->content($json->encode($data));

eval {
my $post = $agent->post($url, @args);
my $post = $agent->request($req);
$response = $json->decode($post->content);
};
if ($@ || (! ref($response))) {
$self->application->add_message('warning', "Could not make metagenome public: ".$@);
return 1;
return "<pre>Could not make metagenome public: ".$@."</pre>";
} elsif (exists($response->{ERROR}) && $response->{ERROR}) {
$self->application->add_message('warning', "Could not make metagenome public: ". $response->{ERROR});
return 1;
return "<pre>Could not make metagenome public: ".$response->{ERROR}."</pre>";
}

# send email
Expand Down