fix int_of_string on input

This commit is contained in:
Swrup 2022-03-08 18:48:12 +01:00
parent 67f3a6eb3d
commit c2d4d03555

View file

@ -269,13 +269,15 @@ let profile_post request =
"Your display nick was updated!" "Your display nick was updated!"
| Error e -> render_unsafe e request ) | Error e -> render_unsafe e request )
| `Ok [ ("content", content); ("count", count); ("label", label) ] -> ( | `Ok [ ("content", content); ("count", count); ("label", label) ] -> (
let count = int_of_string count in match int_of_string_opt count with
| None -> render_unsafe "Error: invalid count" request
| Some count -> (
match User.update_metadata count label content nick with match User.update_metadata count label content nick with
| Ok () -> | Ok () ->
Dream.respond ~status:`See_Other Dream.respond ~status:`See_Other
~headers:[ ("Location", "/profile") ] ~headers:[ ("Location", "/profile") ]
"Your display nick was updated!" "Your display nick was updated!"
| Error e -> render_unsafe e request ) | Error e -> render_unsafe e request ) )
| `Ok _ | `Many_tokens _ | `Missing_token _ | `Invalid_token _ | `Ok _ | `Many_tokens _ | `Missing_token _ | `Invalid_token _
| `Wrong_session _ | `Expired _ | `Wrong_content_type -> ( | `Wrong_session _ | `Expired _ | `Wrong_content_type -> (
match%lwt Dream.multipart request with match%lwt Dream.multipart request with