web: Put session file in $XDG_DATA_DIR. (#1344)

* web: Put session file in $XDG_DATA_DIR.

* web: Use $XDG_CACHE_HOME instead of $XDG_DATA_HOME.

* web: Force minimum version of directory (needed for xdg utilities).

* web: Cancel changes to hledger-web.cabal

Co-authored-by: Félix Sipma <felix.sipma@no-log.org>
This commit is contained in:
legrostdg 2020-09-10 17:37:33 +02:00 committed by GitHub
parent 8e1b5e784b
commit 1dfc7e1116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -31,7 +31,9 @@ import Data.Time.Calendar (Day)
import Network.HTTP.Conduit (Manager)
import Network.HTTP.Types (status403)
import Network.Wai (requestHeaders)
import System.FilePath (takeFileName)
import System.Directory (XdgDirectory (..), createDirectoryIfMissing,
getXdgDirectory)
import System.FilePath (takeFileName, (</>))
import Text.Blaze (Markup)
import Text.Hamlet (hamletFile)
import Yesod
@ -100,9 +102,11 @@ type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget)
instance Yesod App where
approot = ApprootMaster $ appRoot . settings
makeSessionBackend _ =
makeSessionBackend _ = do
hledgerdata <- getXdgDirectory XdgCache "hledger"
createDirectoryIfMissing True hledgerdata
let sessionexpirysecs = 120
in Just <$> defaultClientSessionBackend sessionexpirysecs ".hledger-web_client_session_key.aes"
Just <$> defaultClientSessionBackend sessionexpirysecs (hledgerdata </> "hledger-web_client_session_key.aes")
-- defaultLayout :: WidgetFor site () -> HandlerFor site Html
defaultLayout widget = do

View File

@ -115,7 +115,7 @@ library:
- containers
- data-default
- Decimal >=0.5.1
- directory
- directory >=1.2.3.0
- extra >=1.6.3
- filepath
- hjsmin