package sihl
The modular functional web framework
Install
Dune Dependency
Authors
Maintainers
Sources
sihl-queue-0.1.6.tbz
sha256=574c73c97ea0bc57144853b28df6125855a040ef0378f3bf180b4331dde93f9d
sha512=92c474ed3b6609395799f77259fc424af37dcad53095773ca2f2cdd4757a1607a5b53b6594cd7b6ddabeb40ebba67bb9544ff0f31dc228c87cfe015afa520aaa
doc/src/sihl.authn/service.ml.html
Source file service.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
open Lwt.Syntax exception Exception of string let log_src = Logs.Src.create ~doc:"authn" "sihl.service.authn" module Logs = (val Logs.src_log log_src : Logs.LOG) module Make (SessionService : Session.Sig.SERVICE) (UserService : User.Sig.SERVICE) : Sig.SERVICE = struct let find_user_in_session_opt ctx session = let* user_id = SessionService.get ctx session ~key:"authn" in match user_id with | None -> Lwt.return None | Some user_id -> UserService.find_opt ctx ~user_id ;; let find_user_in_session ctx session = let* user_id = SessionService.get ctx session ~key:"authn" in match user_id with | None -> raise @@ Exception "No user found in current session" | Some user_id -> UserService.find ctx ~user_id ;; let authenticate_session ctx user session = SessionService.set ctx session ~key:"authn" ~value:(User.id user) ;; let unauthenticate_session ctx session = SessionService.unset ctx session ~key:"authn" let start ctx = Lwt.return ctx let stop _ = Lwt.return () let lifecycle = Core.Container.Lifecycle.create "authn" ~start ~stop ~dependencies:[ SessionService.lifecycle; UserService.lifecycle ] ;; let configure configuration = let configuration = Core.Configuration.make configuration in Core.Container.Service.create ~configuration lifecycle ;; end
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>