snaplet-persistent-0.5: persistent snaplet for the Snap Framework

Safe HaskellNone





initPersistAuthManager :: SnapletLens b SessionManager -> ConnectionPool -> SnapletInit b (AuthManager b) Source

Initializer that gets AuthSettings from a config file.

initPersistAuthManager' :: AuthSettings -> SnapletLens b SessionManager -> ConnectionPool -> SnapletInit b (AuthManager b) Source

Initializer that lets you specify AuthSettings.

authEntityDefs :: [EntityDef] Source

The list of entity definitions this snaplet exposes. You need them so that you can append to your application's list of entity definitions and perform the migration in one block.

See how this example combined an app's own entity definitions and the auth snaplet's in one migration block:

share [mkMigrate "migrateAll"] $
   authEntityDefs ++
   $(persistFileWith lowerCaseSettings "schema.txt")

Persistent Auth Data Types

Persistent creates its own data types mirroring the database schema, so we have to export this extra layer of types and conversion to AuthUser.

data SnapAuthUser Source


PersistFieldSql SnapAuthUser 
PersistEntity SnapAuthUser 
PersistField SnapAuthUser 
ToBackendKey SqlBackend SnapAuthUser 
Eq (Key SnapAuthUser) 
Ord (Key SnapAuthUser) 
Read (Key SnapAuthUser) 
Show (Key SnapAuthUser) 
ToJSON (Key SnapAuthUser) 
FromJSON (Key SnapAuthUser) 
PathPiece (Key SnapAuthUser) 
PersistFieldSql (Key SnapAuthUser) 
PersistField (Key SnapAuthUser) 
data Unique SnapAuthUser 
data EntityField SnapAuthUser where 
data Key SnapAuthUser = SnapAuthUserKey {} 
type PersistEntityBackend SnapAuthUser = SqlBackend 

db2au :: Entity SnapAuthUser -> AuthUser Source

Function to convert a SnapAuthUser entity into the auth snaplet's AuthUser.

dbUserSplices :: Monad n => Splices (RuntimeSplice n (Entity SnapAuthUser) -> Splice n) Source

Splices for SnapAuthUser that are equivalent to the ones for AuthUser.