Skip to content

Instantly share code, notes, and snippets.

@milaz
Created February 10, 2012 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milaz/1793058 to your computer and use it in GitHub Desktop.
Save milaz/1793058 to your computer and use it in GitHub Desktop.
Adding HashDB authentication
diff --git a/Application.hs b/Application.hs
index 797b7fb..0de5747 100644
--- a/Application.hs
+++ b/Application.hs
@@ -8,6 +8,7 @@ import Import
import Settings
import Settings.StaticFiles (staticSite)
import Yesod.Auth
+import Yesod.Auth.HashDB
import Yesod.Default.Config
import Yesod.Default.Main
import Yesod.Default.Handlers
@@ -43,6 +44,7 @@ getApplication conf logger = do
Database.Persist.Store.applyEnv
p <- Database.Persist.Store.createPoolConfig (dbconf :: Settings.PersistConfig)
Database.Persist.Store.runPool dbconf (runMigration migrateAll) p
+ Database.Persist.Store.runPool dbconf (runMigration migrateUsers) p
let foundation = FCCS conf setLogger s p manager dbconf
app <- toWaiAppPlain foundation
return $ logWare app
diff --git a/Foundation.hs b/Foundation.hs
index e4385fb..e9280f1 100644
--- a/Foundation.hs
+++ b/Foundation.hs
@@ -17,8 +17,9 @@ import Yesod
import Yesod.Static
import Settings.StaticFiles
import Yesod.Auth
-import Yesod.Auth.BrowserId
-import Yesod.Auth.GoogleEmail
+import Yesod.Auth.HashDB
+-- import Yesod.Auth.BrowserId
+-- import Yesod.Auth.GoogleEmail
import Yesod.Default.Config
import Yesod.Default.Util (addStaticContentExternal)
import Yesod.Logger (Logger, logMsg, formatLogText)
@@ -141,7 +142,7 @@ instance YesodAuth FCCS where
loginDest _ = RootR
-- Where to send a user after logout
logoutDest _ = RootR
-
+{-
getAuthId creds = runDB $ do
x <- getBy $ UniqueUser $ credsIdent creds
case x of
@@ -151,9 +152,14 @@ instance YesodAuth FCCS where
-- You can add other plugins like BrowserID, email or OAuth here
authPlugins _ = [authBrowserId, authGoogleEmail]
+-}
+
+ getAuthId = getAuthIdHashDB AuthR (Just . UniqueUser)
+ authPlugins = [authHashDB (Just . UniqueUser)]
authHttpManager = httpManager
+
-- Sends off your mail. Requires sendmail in production!
deliver :: FCCS -> L.ByteString -> IO ()
#ifdef DEVELOPMENT
Foundation.hs:139:24:
Ambiguous occurrence `UserId'
It could refer to either `Yesod.Auth.HashDB.UserId',
imported from `Yesod.Auth.HashDB' at Foundation.hs:20:1-24
or `Model.UserId',
imported from `Model' at Foundation.hs:35:1-12
Foundation.hs:157:49:
Ambiguous occurrence `UniqueUser'
It could refer to either `Yesod.Auth.HashDB.UniqueUser',
imported from `Yesod.Auth.HashDB' at Foundation.hs:20:1-24
or `Model.UniqueUser',
imported from `Model' at Foundation.hs:35:1-12
Foundation.hs:158:39:
Ambiguous occurrence `UniqueUser'
It could refer to either `Yesod.Auth.HashDB.UniqueUser',
imported from `Yesod.Auth.HashDB' at Foundation.hs:20:1-24
or `Model.UniqueUser',
imported from `Model' at Foundation.hs:35:1-12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment