Added better exit code on upload and commented out currently non-functional code

This commit is contained in:
piratefinn 2016-09-05 16:40:41 +01:00
parent ffcce58fc4
commit 605842c40e

View file

@ -25,11 +25,11 @@ any '/' => sub {
post '/upload' => sub { post '/upload' => sub {
my $self = shift; my $self = shift;
# Fetch parameters to write to DB # Fetch parameters to write to DB
my $key = $self->param('key'); # my $key = $self->param('key');
# This will include an if function to see if key matches # This will include an if function to see if key matches
unless ($key eq $config->{key}) { # unless ($key eq $config->{key}) {
return $self->render( json => { success => Mojo::JSON->false }, status => 403 ); # return $self->render( json => { success => Mojo::JSON->false }, status => 403 );
} # }
my $username = $self->param('username'); my $username = $self->param('username');
my $company = $self->param('company'); my $company = $self->param('company');
my $currency = $self->param('currency'); my $currency = $self->param('currency');
@ -38,7 +38,10 @@ post '/upload' => sub {
my $headers = $file->headers->content_type; my $headers = $file->headers->content_type;
# Is content type wrong? # Is content type wrong?
if ($headers ne 'image/jpeg') { if ($headers ne 'image/jpeg') {
print "Upload fail. Content type is wrong.\n"; return $self->render( json => {
success => Mojo::JSON->false,
message => 'Wrong image extension!',
});
}; };
# Rewrite header data # Rewrite header data
my $ext = '.jpg'; my $ext = '.jpg';