]> git.plutz.net Git - lobster/commitdiff
mark end of form submission to prevent incomplete updates
authorPaul Hänsch <paul@plutz.net>
Tue, 25 Aug 2020 02:32:33 +0000 (04:32 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 25 Aug 2020 02:32:33 +0000 (04:32 +0200)
therapies/page.sh
therapies/update_therapy.sh

index fb86050e1399d0d9030f62a0e3156c5cf0df620c..bbe845b66f2b76ea2b1e4a6f396a7fcd28158924 100755 (executable)
@@ -215,6 +215,7 @@ cat <<EOF
   [canvas #canvas .dotmark .ov width="${bg_dim%x*}" height="${bg_dim#*x}" ]
   [input type=hidden #image_serialize name=imagedata value=""]
 
+  [input type=hidden name=formend value=formend]
   [button #savebutton type=submit $(l10n save)]
 ]
 
index bb3901fbe21f66d3cbf6ecafb87d39e9ff1afc68..70fdea2930a23b0391a1ec7b58df693f8e5e8b07 100755 (executable)
@@ -28,7 +28,17 @@ if [ "$(POST tid)" != "$(transid "$tpyfile")" ]; then
     printf 'Status: 409 Conflict\r\nContent-Length: 0\r\n\r\n'
     exit 0
   else
-    SET_COOKIE session message="TRANSACTION CONFLICT"
+    SET_COOKIE session message="TRANSACTION_CONFLICT"
+    REDIRECT "/therapies/${tpy%.*}/${tpy#*.}"
+  fi
+fi
+
+if [ "$(POST formend)" != "formend" ]; then
+  if [ "$(POST autosubmit)" = "true" ]; then
+    printf 'Status: 409 Conflict\r\nContent-Length: 0\r\n\r\n'
+    exit 0
+  else
+    SET_COOKIE session message="INCOMPLETE_SUBMIT"
     REDIRECT "/therapies/${tpy%.*}/${tpy#*.}"
   fi
 fi
@@ -36,7 +46,7 @@ fi
 # serialize POST array into file
 for key in $(POST_KEYS); do
   case "$key" in
-    imagedata|tid) : ;;
+    imagedata|tid|formend) : ;;
     session*_date)
       value="$(POST "$key")"
       y=0 mon=0 dom=0