From 61889603f7699b64ab90674cf8cf200d40cb83bd Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 30 Dec 2019 01:31:26 +0100 Subject: Checkin API: error out if fromStation / toStation are ambiguous --- lib/Travelynx/Controller/Api.pm | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'lib/Travelynx/Controller') diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm index 4546292..b951af4 100755 --- a/lib/Travelynx/Controller/Api.pm +++ b/lib/Travelynx/Controller/Api.pm @@ -185,6 +185,47 @@ sub travel_v1 { return; } + if ( + @{ + [ + Travel::Status::DE::IRIS::Stations::get_station( + $from_station) + ] + } != 1 + ) + { + $self->render( + json => { + success => \0, + deprecated => \0, + error => 'fromStation is ambiguous', + status => $self->get_user_status_json_v1($uid) + }, + ); + return; + } + + if ( + $to_station + and @{ + [ + Travel::Status::DE::IRIS::Stations::get_station( + $to_station) + ] + } != 1 + ) + { + $self->render( + json => { + success => \0, + deprecated => \0, + error => 'toStation is ambiguous', + status => $self->get_user_status_json_v1($uid) + }, + ); + return; + } + if ( exists $payload->{train}{id} ) { $train_id = sanitize( 0, $payload->{train}{id} ); } -- cgit v1.2.3