Warning: Reason support is experimental. We are looking for beta-tester and contributors.

Protecting your passwords

For protecting the user passwords or other sensitive data, we can use ocaml-safepass.

We can now write the encrypted password in our database using Ocsipersist.‚Äčtable as follow:

let table =
  Ocsipersist.open_table "users"

let add_user username password =
  (* Check if the user is already exist *)
    (fun () -> Ocsipersist.find table username)
    (fun _ -> Lwt.return false)
      | Not_found ->
        Ocsipersist.add table username
          (Bcrypt.hash password, email)
        >>= fun () ->
        Lwt.return true
      | e -> Lwt.fail e