Skip to content

Commit eef404a

Browse files
committed
Use the persistent auth backend
1 parent 9006def commit eef404a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: src/Site.hs

+4-6
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ module Site
1010

1111
------------------------------------------------------------------------------
1212
import Control.Applicative
13+
import Control.Lens.Getter
1314
import Data.ByteString (ByteString)
1415
import Data.Monoid
1516
import qualified Data.Text as T
1617
import Snap.Core
1718
import Snap.Snaplet
1819
import Snap.Snaplet.Auth
19-
import Snap.Snaplet.Auth.Backends.JsonFile
20+
import Snap.Snaplet.Auth.Backends.Persistent
2021
import Snap.Snaplet.Persistent
2122
import Snap.Snaplet.Heist
2223
import Snap.Snaplet.Session.Backends.CookieSession
@@ -83,11 +84,8 @@ app = makeSnaplet "app" "An snaplet example application." Nothing $ do
8384

8485
p <- nestSnaplet "" db $ initPersist (runMigrationUnsafe migrateAll)
8586

86-
-- NOTE: We're using initJsonFileAuthManager here because it's easy and
87-
-- doesn't require any kind of database server to run. In practice,
88-
-- you'll probably want to change this to a more robust auth backend.
89-
a <- nestSnaplet "auth" auth $
90-
initJsonFileAuthManager defAuthSettings sess "users.json"
87+
a <- nestSnaplet "auth" auth $ initPersistAuthManager sess (persistPool $ view snapletValue p)
88+
9189
addRoutes routes
9290
addAuthSplices h auth
9391
return $ App h s a p

0 commit comments

Comments
 (0)