Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Admin/FrontController.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Admin.View.Layout

-- Controller Imports
import Admin.Controller.Admins
import IHP.LoginSupport.Middleware
import Admin.Controller.Sessions

instance FrontController AdminApplication where
Expand All @@ -23,4 +22,3 @@ instance FrontController AdminApplication where
instance InitControllerContext AdminApplication where
initContext = do
setLayout defaultLayout
initAuthentication @Admin
2 changes: 0 additions & 2 deletions Admin/View/Layout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ defaultLayout inner = [hsx|
</body>
</html>
|]
where
currentAdminOrNothing = fromFrozenContext @(Maybe Admin)

renderLoggedInAs :: Maybe Admin -> Html
renderLoggedInAs (Just admin) = [hsx|
Expand Down
4 changes: 1 addition & 3 deletions Application/Helper/Controller.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ module Application.Helper.Controller
import IHP.LoginSupport.Helper.Controller
import IHP.Prelude
import Generated.Types
import Application.Helper.TypeInstances ()

import qualified Network.Wreq as Wreq
import qualified Config
import qualified Control.Concurrent.Async as Async
import Data.Aeson

type instance CurrentUserRecord = User
type instance CurrentAdminRecord = Admin

sendToSlack :: Text -> IO ()
sendToSlack message = case Config.slackWebHook of
Just slackWebHook -> do
Expand Down
13 changes: 13 additions & 0 deletions Application/Helper/TypeInstances.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- | Orphan instances for 'IHP.LoginSupport.Types.CurrentUserRecord' and
-- 'IHP.LoginSupport.Types.CurrentAdminRecord'.
--
-- Keeping these in their own tiny module avoids import cycles when
-- `Config/Config.hs` (which can't import `Application.Helper.Controller`)
-- needs the instances in scope for 'authMiddleware @User'.
module Application.Helper.TypeInstances () where

import Generated.Types
import IHP.LoginSupport.Types

type instance CurrentUserRecord = User
type instance CurrentAdminRecord = Admin
5 changes: 4 additions & 1 deletion Config/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ module Config where
import IHP.Prelude
import IHP.Environment
import IHP.FrameworkConfig
import qualified IHP.LoginSupport.Middleware as Auth
import Application.Helper.TypeInstances ()
import Generated.Types

config :: ConfigBuilder
config = do
-- See https://ihp.digitallyinduced.com/Guide/config.html
-- for what you can do here
pure ()
option $ AuthMiddleware (Auth.authMiddleware @User . Auth.adminAuthMiddleware @Admin)

slackWebHook :: Maybe String
slackWebHook = Nothing
2 changes: 0 additions & 2 deletions Web/FrontController.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Web.Controller.Topics
import Web.Controller.Comments
import Web.Controller.Users
import Web.Controller.Threads
import IHP.LoginSupport.Middleware
import Web.Controller.Sessions

instance FrontController WebApplication where
Expand All @@ -28,4 +27,3 @@ instance FrontController WebApplication where
instance InitControllerContext WebApplication where
initContext = do
setLayout defaultLayout
initAuthentication @User