summaryrefslogtreecommitdiff
path: root/lib/Travelynx.pm
diff options
context:
space:
mode:
authorDerf Null <derf@finalrewind.org>2023-03-10 17:18:08 +0100
committerDerf Null <derf@finalrewind.org>2023-03-10 17:18:08 +0100
commitabc1e4e3a8f94682076eb6d588c1b521ae71e98a (patch)
tree37f23f3ee2af040d55fa10a8dacc286ffbde7a65 /lib/Travelynx.pm
parentf79e34fb622ddb5cf394da9928fa981c36ba3ad8 (diff)
work: avoid race conditions with frontend when calling checkout
Diffstat (limited to 'lib/Travelynx.pm')
-rwxr-xr-xlib/Travelynx.pm8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index aae5746..8ec3c8e 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -553,6 +553,8 @@ sub startup {
my ( $self, %opt ) = @_;
my $station = $opt{station};
+ my $dep_eva = $opt{dep_eva};
+ my $arr_eva = $opt{arr_eva};
my $force = $opt{force};
my $uid = $opt{uid};
my $db = $opt{db} // $self->pg->db;
@@ -576,6 +578,12 @@ sub startup {
if ( $status->{errstr} and not $force ) {
return ( 1, $status->{errstr} );
}
+ if ( $dep_eva and $dep_eva != $user->{dep_eva} ) {
+ return ( 0, 'race condition' );
+ }
+ if ( $arr_eva and $arr_eva != $user->{arr_eva} ) {
+ return ( 0, 'race condition' );
+ }
my $now = DateTime->now( time_zone => 'Europe/Berlin' );
my $journey = $self->in_transit->get(