From 94a37fe51f2ea8d590d81d49271211a0f5b1310c Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Wed, 21 Dec 2022 08:46:04 -0800 Subject: [PATCH] Extract secrets in helper to single definition. --- examples/end-to-end/src/MySession.elm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/end-to-end/src/MySession.elm b/examples/end-to-end/src/MySession.elm index 783ce077..aa7410ae 100644 --- a/examples/end-to-end/src/MySession.elm +++ b/examples/end-to-end/src/MySession.elm @@ -24,7 +24,7 @@ withSession : withSession = Session.withSession { name = "mysession" - , secrets = Env.expect "SESSION_SECRET" |> DataSource.map List.singleton + , secrets = secrets , options = cookieOptions } @@ -36,7 +36,7 @@ withSessionOrRedirect : withSessionOrRedirect toRequest handler = Session.withSession { name = "mysession" - , secrets = Env.expect "SESSION_SECRET" |> DataSource.map List.singleton + , secrets = secrets , options = cookieOptions } (\request sessionResult -> @@ -52,6 +52,11 @@ withSessionOrRedirect toRequest handler = handler +secrets : DataSource (List String) +secrets = + Env.expect "SESSION_SECRET" |> DataSource.map List.singleton + + expectSessionOrRedirect : (request -> Session.Session -> DataSource ( Session.Session, Response data errorPage )) -> Parser request @@ -59,7 +64,7 @@ expectSessionOrRedirect : expectSessionOrRedirect toRequest handler = Session.withSession { name = "mysession" - , secrets = Env.expect "SESSION_SECRET" |> DataSource.map List.singleton + , secrets = secrets , options = cookieOptions } (\request sessionResult ->