decided not to use auth in the end
This commit is contained in:
parent
ab707af870
commit
ce2dd6c750
1 changed files with 1 additions and 25 deletions
|
|
@ -44,11 +44,7 @@ import System.Log.FastLogger (defaultBufSize, newStdoutLoggerSet,
|
||||||
-- Import all relevant handler modules here.
|
-- Import all relevant handler modules here.
|
||||||
-- Don't forget to add new modules to your cabal file!
|
-- Don't forget to add new modules to your cabal file!
|
||||||
import Handler.Common
|
import Handler.Common
|
||||||
import Handler.Home
|
|
||||||
import Handler.TodoEntry
|
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
|
-- 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
|
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
||||||
|
|
@ -193,23 +189,3 @@ handler h = getAppSettings >>= makeFoundation >>= flip unsafeHandler h
|
||||||
-- | Run DB queries
|
-- | Run DB queries
|
||||||
db :: ReaderT SqlBackend Handler a -> IO a
|
db :: ReaderT SqlBackend Handler a -> IO a
|
||||||
db = handler . runDB
|
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
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue