From c63309b9e86e50c45e99fce09b4dec816d9b74c1 Mon Sep 17 00:00:00 2001 From: Stuce Date: Wed, 2 Jul 2025 17:13:50 +0100 Subject: [PATCH] removed middleware --- src/Foundation.hs | 20 ++++++++------------ src/Handler/Group.hs | 6 ------ src/Handler/Todolist.hs | 8 -------- src/Handler/TodolistItem.hs | 12 ------------ 4 files changed, 8 insertions(+), 38 deletions(-) diff --git a/src/Foundation.hs b/src/Foundation.hs index ffb4191..39678d4 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -20,8 +20,6 @@ import Control.Monad.Logger (LogSource) import Yesod.Default.Util (addStaticContentExternal) import Yesod.Core.Types (Logger) import qualified Yesod.Core.Unsafe as Unsafe -import qualified Data.CaseInsensitive as CI -import qualified Data.Text.Encoding as TE -- | The foundation datatype for your application. This can be a good place to -- keep settings and values requiring initialization before your application @@ -91,8 +89,8 @@ instance Yesod App where -- b) Validates that incoming write requests include that token in either a header or POST parameter. -- To add it, chain it together with the defaultMiddleware: yesodMiddleware = defaultYesodMiddleware . defaultCsrfMiddleware -- For details, see the CSRF documentation in the Yesod.Core.Handler module of the yesod-core package. - yesodMiddleware :: ToTypedContent res => Handler res -> Handler res - yesodMiddleware = defaultYesodMiddleware . defaultCsrfMiddleware + -- yesodMiddleware :: ToTypedContent res => Handler res -> Handler res + -- yesodMiddleware = defaultYesodMiddleware . defaultCsrfMiddleware defaultLayout :: Widget -> Handler Html defaultLayout widget = do @@ -111,13 +109,12 @@ instance Yesod App where $(widgetFile "default-layout") withUrlRenderer $(hamletFile "templates/default-layout-wrapper.hamlet") - isAuthorized - :: Route App -- ^ The route the user is visiting. - -> Bool -- ^ Whether or not this is a "write" request. - -> Handler AuthResult - -- Routes not requiring authentication. - -- TODO: check this bullshit if need to change it or not (prolly authelia problem) - isAuthorized _ _ = return Authorized + -- isAuthorized + -- :: Route App -- ^ The route the user is visiting. + -- -> Bool -- ^ Whether or not this is a "write" request. + -- -> Handler AuthResult + -- -- Routes not requiring authentication. + -- isAuthorized _ _ = return Authorized -- This function creates static content files in the static folder @@ -208,7 +205,6 @@ getUserId = do dbIfAuth :: GroupId -> ReaderT SqlBackend (HandlerFor App) b -> HandlerFor App b dbIfAuth groupId action = do -- TODO: decide if we prefer fast (rawSql) or safe (type safe persist query) after in production latency tests - -- TODO: optimize the persist implementation anyway user <- getUserId result <- runDB $ selectFirst [GroupUserUser ==. user, GroupUserGroupId ==. groupId] [] if isNothing result then permissionDenied "you are not logged in or you dont have access to this group" diff --git a/src/Handler/Group.hs b/src/Handler/Group.hs index c2f4bb5..287cedd 100644 --- a/src/Handler/Group.hs +++ b/src/Handler/Group.hs @@ -16,7 +16,6 @@ getGroupR :: Handler Html getGroupR = do userId <- getUserId groups <- getGroups userId - mToken <- fmap reqToken getRequest defaultLayout $ do setTitle "Groups" [whamlet| @@ -27,8 +26,6 @@ getGroupR = do #{(groupGroup . entityVal) group}
- $maybe token <- mToken -