Parameter Make.1-UserService
module Web : sig ... endval search : ?ctx:(string * string) list -> ?sort:[ `Desc | `Asc ] -> ?filter:string -> ?limit:int -> ?offset:int -> unit -> (Sihl.Contract.User.t list * int) Lwt.tsearch ?ctx ?sort ?filter ?limit ?offset ()returns a list of users that is a partial view on all stored users.sortis the default sorting order of the created date. By default, this value is`Desc.filteris 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).limitis the length of the returned list.offsetis the pagination offset of the partial view.
val find_opt : ?ctx:(string * string) list -> string -> Sihl.Contract.User.t option Lwt.tfind_opt ?ctx idreturns a user withid.
val find : ?ctx:(string * string) list -> string -> Sihl.Contract.User.t Lwt.tfind ?ctx idreturns a user withid,Noneotherwise.
val find_by_email : ?ctx:(string * string) list -> string -> Sihl.Contract.User.t Lwt.tfind_by_email ?ctx emailreturns aUser.tif there is a user with email addressemail. 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.tfind_by_email_opt ?ctx emailreturns aUser.tif there is a user with email addressemail.
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.tupdate_password ?ctx ?password_policy user ~old_password ~new_password ~new_password_confirmationupdates the password of ausertonew_passwordand returns the user. Theold_passwordis the current password that the user has to enter.new_passwordhas to equalnew_password_confirmation.password_policyis a function that validates thenew_passwordbased 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.tupdate ?ctx?email ?username ?name ?given_name ?status userstores the updateduserand returns it.
val update_details : user:Sihl.Contract.User.t -> email:string -> username:string option -> Sihl.Contract.User.t Lwt.tval 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.tset_password ?ctx ?policy user ~password ~password_confirmationoverrides the current password of auserand returns that user.passwordhas to equalpassword_confirmation.password_policyis a function that validates thenew_passwordbased 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_passwordinstead.
val create_user : ?ctx:(string * string) list -> ?username:string -> ?name:string -> ?given_name:string -> password:string -> string -> Sihl.Contract.User.t Lwt.tcreate_user ?ctx ?username ?name ?given_name email passwordreturns a non-admin user. Note that usingcreate_userskips the registration workflow and should only be used with care.
val create_admin : ?ctx:(string * string) list -> ?username:string -> ?name:string -> ?given_name:string -> password:string -> string -> Sihl.Contract.User.t Lwt.tcreate_admin ?ctx ?username ?name ?given_name email passwordreturns an admin user.
val register_user : ?ctx:(string * string) list -> ?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.tregister_user ?ctx ?password_policy ?username ?name ?given_name email password password_confirmationcreates a new user if the password is valid and if the email address was not already registered.Provide
password_policyto 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.tlogin ?ctx email ~passwordreturns the user associated withemailifpasswordmatches the current password.
val register : unit -> Sihl__.Core_container.Service.t
include Sihl__.Core_container.Service.Sig
val lifecycle : Sihl__.Core_lifecycle.lifecycle