Random generation of xkcd-style passwords now functioning as expected, web interface now serves randomly generated xkcd-style passwords and provides a button to create a sharing link for them when a new generation is requested. Misc stylesheet updates. Generalized the hx-vals helper function in Core.Templates to be useful for arbitrary endpoints that will need to include specific JSON. Added configuration field for dbSalt which will be used as an encryption salt in the next commit when passwods are stored encrypted in the DB instead of in plaintext.

This commit is contained in:
2022-07-29 17:40:45 -05:00
parent b1a4251d95
commit bbe315c450
15 changed files with 142 additions and 29 deletions

View File

@ -2,8 +2,9 @@ module Core.HTTP ( app ) where
import Core.Types
import Core.Templates (renderIndex, renderStyle)
import Feature.Sharing.HTTP as Sharing
import Core.Templates (renderIndex, renderStyle)
import Feature.Sharing.HTTP as Sharing
import Feature.Generation.HTTP as Generation
import Data.Maybe (Maybe (Nothing))
import Network.Wai.Middleware.RequestLogger (logStdoutDev)
@ -26,3 +27,4 @@ app = do
-- Feature Routes
Sharing.routes
Generation.routes

View File

@ -1,7 +1,7 @@
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
module Core.Templates ( renderIndex, renderStyle ) where
module Core.Templates ( renderIndex, renderStyle, hxVals ) where
import Text.Blaze.Html.Renderer.Text (renderHtml)
import Text.Blaze.Html
@ -16,10 +16,10 @@ import Prelude
renderIndex :: String -> LT.Text
renderIndex link = renderHtml ( $(shamletFile "./views/index.hamlet") )
where
hsUserLink = userLinkAttr link
hsUserLink = hxVals "userLink" link
renderStyle :: LT.Text
renderStyle = renderCss ( $(cassiusFile "./views/cassius/style.cassius") "/style.css" )
userLinkAttr :: String -> (String, String)
userLinkAttr str = ("hx-vals", "{\"userLink\": \"" <> str <> "\"}")
hxVals :: String -> String -> (String, String)
hxVals attr str = ("hx-vals", "{\"" <> attr <> "\": \"" <> str <> "\"}")

View File

@ -20,5 +20,6 @@ data DhallConfig = DhallConfig
, applicationHost :: String
, applicationPort :: Int
, dbFile :: String
, dbSalt :: String
, linkLength :: Int
} deriving (Generic, Show)