Something went wrong. Try again.
a web app for chore tracking
Something went wrong. Try again.
1234567891011121314151617181920let authenticated_user : string Dream.field = Dream.new_field ()let verify t = if t = "traverse" then Some "clementd" else None
let require_auth inner_handler request = let cookie = Dream.cookie ~decrypt:false request "chore_token" in match cookie with | None -> let headers = [ ("Location", "/login") ] in Dream.respond ~code:303 ~headers "please login" | Some c -> ( match verify c with | None -> let headers = [ ("Location", "/login") ] in Dream.respond ~code:303 ~headers "please login" | Some u -> Dream.set_field request authenticated_user u; inner_handler request)
let get_authenticated_user request = Dream.field request authenticated_user