From ce2dd6c750af7d1b6a407868b9e2c2190a202956 Mon Sep 17 00:00:00 2001 From: Stuce Date: Wed, 25 Jun 2025 11:13:18 +0100 Subject: [PATCH] decided not to use auth in the end --- src/Application.hs | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/Application.hs b/src/Application.hs index 314b501..667b72d 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -44,11 +44,7 @@ import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet, -- Import all relevant handler modules here. -- Don't forget to add new modules to your cabal file! import Handler.Common -import Handler.Home import Handler.TodoEntry -import Yesod.Auth -import Database.Persist.Class.PersistUnique (getByValueUniques) -import Database.Persist.SqlBackend.SqlPoolHooks (getAlterBackend) -- This line actually creates our YesodDispatch instance. It is the second half -- of the call to mkYesodData which occurs in Foundation.hs. Please see the @@ -192,24 +188,4 @@ handler h = getAppSettings >>= makeFoundation >>= flip unsafeHandler h -- | Run DB queries db :: ReaderT SqlBackend Handler a -> IO a -db = handler . runDB -instance YesodAuthPersist App -instance YesodAuth App where - type AuthId App = Key User - loginDest _ = HomeR - logoutDest _ = HomeR - - authPlugins _ = [ ] - - authenticate :: (MonadHandler m, HandlerSite m ~ App) => Creds App -> m (AuthenticationResult App) - authenticate _ = liftHandler $ do - mUserName <- lookupHeader "remoteUser" - case mUserName of - Just userNameBS -> do - let userName = decodeUtf8 userNameBS - x <- runDB $ insertBy $ User userName - return $ Authenticated $ - case x of - Left (Entity user _) -> user -- existing user - Right user -> user -- newly added user - Nothing -> notAuthenticated \ No newline at end of file +db = handler . runDB \ No newline at end of file