package sihl-user

  1. Overview
  2. Docs

Parameters

module Repo : sig ... end

Signature

module Web : sig ... end

search ?ctx ?sort ?filter ?limit ?offset () returns a list of users that is a partial view on all stored users.

sort is the default sorting order of the created date. By default, this value is `Desc.

filter is a search keyword that is applied in a best-effort way on user details. The keyword has to occur in only one field (such as email).

limit is the length of the returned list.

offset is the pagination offset of the partial view.

val find_opt : ?ctx:(string * string) list -> string -> Sihl__.Contract_user.t option Lwt.t

find_opt ?ctx id returns a user with id.

val find : ?ctx:(string * string) list -> string -> Sihl__.Contract_user.t Lwt.t

find ?ctx id returns a user with id, None otherwise.

val find_by_email : ?ctx:(string * string) list -> string -> Sihl__.Contract_user.t Lwt.t

find_by_email ?ctx email returns a User.t if there is a user with email address email. The lookup is case-insensitive. Raises an {!Exception} otherwise.

val find_by_email_opt : ?ctx:(string * string) list -> string -> Sihl__.Contract_user.t option Lwt.t

find_by_email_opt ?ctx email returns a User.t if there is a user with email address email.

val update_password : ?ctx:(string * string) list -> ?password_policy:(string -> (unit, string) Result.t) -> Sihl__.Contract_user.t -> old_password:string -> new_password:string -> new_password_confirmation:string -> (Sihl__.Contract_user.t, string) Result.t Lwt.t

update_password ?ctx ?password_policy user ~old_password ~new_password ~new_password_confirmation updates the password of a user to new_password and returns the user. The old_password is the current password that the user has to enter. new_password has to equal new_password_confirmation.

password_policy is a function that validates the new_password based on some password policy. By default, the policy is that a password has to be at least 8 characters long.

val update : ?ctx:(string * string) list -> ?email:string -> ?username:string -> ?name:string -> ?given_name:string -> ?status:Sihl__.Contract_user.status -> Sihl__.Contract_user.t -> Sihl__.Contract_user.t Lwt.t

update ?ctx?email ?username ?name ?given_name ?status user stores the updated user and returns it.

val update_details : user:Sihl__.Contract_user.t -> email:string -> username:string option -> Sihl__.Contract_user.t Lwt.t
  • deprecated Use update() instead
val set_password : ?ctx:(string * string) list -> ?password_policy:(string -> (unit, string) Result.t) -> Sihl__.Contract_user.t -> password:string -> password_confirmation:string -> (Sihl__.Contract_user.t, string) Result.t Lwt.t

set_password ?ctx ?policy user ~password ~password_confirmation overrides the current password of a user and returns that user. password has to equal password_confirmation.

password_policy is a function that validates the new_password based on some password policy. By default, the policy is that a password has to be at least 8 characters long.

The current password doesn't have to be provided, therefore you should not expose this function to users but only admins. If you want the user to update their own password use update_password instead.

val create_user : ?ctx:(string * string) list -> ?id:string -> ?username:string -> ?name:string -> ?given_name:string -> password:string -> string -> Sihl__.Contract_user.t Lwt.t

create_user ?ctx ?id ?username ?name ?given_name email password returns a non-admin user. Note that using create_user skips the registration workflow and should only be used with care.

val create_admin : ?ctx:(string * string) list -> ?id:string -> ?username:string -> ?name:string -> ?given_name:string -> password:string -> string -> Sihl__.Contract_user.t Lwt.t

create_admin ?ctx ?id ?username ?name ?given_name email password returns an admin user.

val register_user : ?ctx:(string * string) list -> ?id:string -> ?password_policy:(string -> (unit, string) Stdlib.result) -> ?username:string -> ?name:string -> ?given_name:string -> string -> password:string -> password_confirmation:string -> (Sihl__.Contract_user.t, [ `Already_registered | `Invalid_password_provided of string ]) Result.t Lwt.t

register_user ?ctx ?id ?password_policy ?username ?name ?given_name email password password_confirmation creates a new user if the password is valid and if the email address was not already registered.

Provide password_policy to check whether the password fulfills certain criteria.

val login : ?ctx:(string * string) list -> string -> password:string -> (Sihl__.Contract_user.t, [ `Does_not_exist | `Incorrect_password ]) Result.t Lwt.t

login ?ctx email ~password returns the user associated with email if password matches the current password.

val register : unit -> Sihl__.Core_service.t
val lifecycle : Sihl__.Core_lifecycle.lifecycle
OCaml

Innovation. Community. Security.