Update foodloopserver.pl
This commit is contained in:
parent
47d09d6215
commit
ba53a035e4
1 changed files with 23 additions and 7 deletions
|
@ -139,14 +139,30 @@ post '/token' => sub {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
helper get_account_by_token => sub {
|
post '/fetchuser' => sub {
|
||||||
my ( $self, $token ) = @_;
|
my $self = shift;
|
||||||
|
|
||||||
return $self->db->selectrow_hashref(
|
my $json = $self->req->json;
|
||||||
"SELECT keyused, username FROM accounts WHERE idkey = ?",
|
|
||||||
{},
|
my $account = $self->get_account_by_username( $json->{username} );
|
||||||
$token,
|
|
||||||
);
|
unless ( defined $account ) {
|
||||||
|
return $self->render( json => {
|
||||||
|
success => Mojo::JSON->false,
|
||||||
|
message => 'Username not recognised, has your token expired?',
|
||||||
|
});
|
||||||
|
# PLUG SECURITY HOLE
|
||||||
|
} elsif ( $account->{keyused} ne 't' ) {
|
||||||
|
return $self->render( json => {
|
||||||
|
success => Mojo::JSON->false,
|
||||||
|
message => 'Token has not been used yet!',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add stuff to send back to user below here!
|
||||||
|
$self->render( json => {
|
||||||
|
success => Mojo::JSON->true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
helper get_account_by_username => sub {
|
helper get_account_by_username => sub {
|
||||||
|
|
Reference in a new issue